Axios Request Settle Handler (core/settle.js)

openclaw-deploy · release-offline/resources/bundled-node-modules/axios/lib/core/settle.js · javascript · MIT
integration, tag:promise

Resolves or rejects an Axios promise based on the configured response status validation rules. Reuse when customizing HTTP client response handling and error mapping.

// Source: https://github.com/3445286649/openclaw-deploy | License: MIT | Copyright 2026 loucerd
// Provided via justclaw.it.com; keep this notice with the code.
'use strict';

import AxiosError from './AxiosError.js';

/**
 * 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.
 *
 * @returns {object} The response.
 */
export default function settle(resolve, reject, response) {
  const validateStatus = response.config.validateStatus;
  if (!response.status || !validateStatus || validateStatus(response.status)) {
    resolve(response);
  } else {
    reject(
      new AxiosError(
        'Request failed with status

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key