mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
19 lines
568 B
JavaScript
19 lines
568 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Resolve or reject a Promise based on response status.
|
|
*
|
|
* @param {Function} resolve A function that resolves the promise.
|
|
* @param {Function} reject A function that rejects the promise.
|
|
* @param {object} response The response.
|
|
*/
|
|
module.exports = function settle(resolve, reject, response) {
|
|
var validateStatus = response.config.validateStatus;
|
|
// Note: status is not exposed by XDomainRequest
|
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
resolve(response);
|
|
} else {
|
|
reject(response);
|
|
}
|
|
};
|