source: imaps-frontend/node_modules/axios/lib/core/settle.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 836 bytes
Line 
1'use strict';
2
3import AxiosError from './AxiosError.js';
4
5/**
6 * Resolve or reject a Promise based on response status.
7 *
8 * @param {Function} resolve A function that resolves the promise.
9 * @param {Function} reject A function that rejects the promise.
10 * @param {object} response The response.
11 *
12 * @returns {object} The response.
13 */
14export default function settle(resolve, reject, response) {
15 const validateStatus = response.config.validateStatus;
16 if (!response.status || !validateStatus || validateStatus(response.status)) {
17 resolve(response);
18 } else {
19 reject(new AxiosError(
20 'Request failed with status code ' + response.status,
21 [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
22 response.config,
23 response.request,
24 response
25 ));
26 }
27}
Note: See TracBrowser for help on using the repository browser.