Repository: axios/axios
File: lib/core/Axios.js (JavaScript)

Code before:
   * @param {?Object} config
   *
   * @returns {Promise} The Promise to be fulfilled
   */
  async request(configOrUrl, config) {
    try {
      return await this._dispatchRequest(configOrUrl, config);
    } catch (err) {
      const dummy = {}
      if (Error.captureStackTrace) {
        Error.captureStackTrace(dummy)
      } else {
        dummy.stack = new Error().stack;
      }
      // slice off the Error: ... line
      dummy.stack = dummy.stack.replace(/^.+\n/g, '');
      // match without the 2 top stack lines
      if (!err.stack.endsWith(dummy.stack.replace(/^.+\n.+\n/g, ''))) {
        err.stack += '\n' + dummy.stack
      }

      throw err;
    }
  }

  _dispatchRequest(configOrUrl, config) {
    /*eslint no-param-reassign:0*/
    // Allow for axios('example/url'[, config]) a la fetch API
    if (typeof configOrUrl === 'string') {
      config = config || {};
      config.url = configOrUrl;
    } else {
      config = configOrUrl || {};
    }

    config = mergeConfig(this.defaults, config);

    const {transitional, paramsSerializer, headers} = config;

    if (transitional !== undefined) {
      validator.assertOptions(transitional, {
        silentJSONParsing: validators.transitional(validators.boolean),
        forcedJSONParsing: validators.transitional(validators.boolean),
        clarifyTimeoutError: validators.transitional(validators.boolean)
      }, false);
    }

    if (paramsSerializer != null) {
      if (utils.isFunction(paramsSerializer)) {
        config.paramsSerializer = {
          serialize: paramsSerializer

Review comment (suggestion):
It would probably be better to call this `_request` for now since we are wrapping the original `request` function

Code after:
   * @returns {Promise} The Promise to be fulfilled
   */
  async request(configOrUrl, config) {
    try {
      return await this._request(configOrUrl, config);
    } catch (err) {
      const dummy = {}
      if (Error.captureStackTrace) {
        Error.captureStackTrace(dummy)
      } else {
        dummy.stack = new Error().stack;
      }
      // slice off the Error: ... line
      dummy.stack = dummy.stack.replace(/^.+\n/, '');
      // match without the 2 top stack lines
      if (!err.stack.endsWith(dummy.stack.replace(/^.+\n.+\n/, ''))) {
        err.stack += '\n' + dummy.stack
      }

      throw err;
    }
  }

  _request(configOrUrl, config) {
    /*eslint no-param-reassign:0*/
    // Allow for axios('example/url'[, config]) a la fetch API
    if (typeof configOrUrl === 'string') {
      config = config || {};
      config.url = configOrUrl;
    } else {
      config = configOrUrl || {};
    }

    config = mergeConfig(this.defaults, config);

    const {transitional, paramsSerializer, headers} = config;

    if (transitional !== undefined) {
      validator.assertOptions(transitional, {
        silentJSONParsing: validators.transitional(validators.boolean),
        forcedJSONParsing: validators.transitional(validators.boolean),
        clarifyTimeoutError: validators.transitional(validators.boolean)
      }, false);
    }

    if (paramsSerializer != null) {
      if (utils.isFunction(paramsSerializer)) {
        config.paramsSerializer = {
          serialize: paramsSerializer
        }
      } else {