平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settle.js 518 B

2 months ago
12345678910111213141516
  1. /**
  2. * Resolve or reject a Promise based on response status.
  3. *
  4. * @param {Function} resolve A function that resolves the promise.
  5. * @param {Function} reject A function that rejects the promise.
  6. * @param {object} response The response.
  7. */
  8. export default function settle(resolve, reject, response) {
  9. const validateStatus = response.config.validateStatus
  10. const status = response.statusCode
  11. if (status && (!validateStatus || validateStatus(status))) {
  12. resolve(response)
  13. } else {
  14. reject(response)
  15. }
  16. }