axios icon indicating copy to clipboard operation
axios copied to clipboard

this.request is not a function

Open rizaldirnm opened this issue 3 years ago • 0 comments

Describe the bug

I got receive error report from Sentry.

CleanShot 2022-09-06 at 08 33 34@2x

I have no idea what is this.

the function in core/http/http.ts looks like:

export const apiInstance = axios.create({
  timeout: API_TIMEOUT,
  baseURL: BASE_URL,
});


/**
 * handle HTTP GET to RestAPI
 */
export const get = <T = any>(
  endpoint: string,
  queryParam: any = {},
  config?: AxiosRequestConfig
) => {
  /**
   * Url endpoint
   */
  let url = endpoint;
  /**
   * Add query param when `queryParam` is given
   */
  if (queryParam && Object.keys(queryParam).length > 0) {
    url = url + '?' + serializeParam(queryParam);
  }

  const newConfig: AxiosRequestConfig = {
    // attach config from param function
    ...config,
    headers: {
      ...config?.headers,
      'content-type': 'application/json',
    },
  };

  return apiInstance.get<T>(url, newConfig);
};

Up until now only 1 event occur in sentry. Is it possible error from axios lib? Or something wrong with my implementation?

To Reproduce

Its so rare, I cant even reproduce it.

Expected behavior

Sentry should not showing an error.

Environment

  • Axios Version 0.27.2
  • Browser Chrome Mobile WebView 104.0.5112
  • Browser Version 104.0.5112
  • OS: Android 7.1.1
  • Device: SAMSUNG SM-J250F

Thank you in advance!

rizaldirnm avatar Sep 06 '22 01:09 rizaldirnm