|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
846 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | import 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 | */
|
|---|
| 14 | export 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 | response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE,
|
|---|
| 22 | response.config,
|
|---|
| 23 | response.request,
|
|---|
| 24 | response
|
|---|
| 25 | ));
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.