https://supertokens.com/ logo
#support-questions
Title
# support-questions
z

ZeferiniX

09/05/2021, 1:06 PM
then I guess that's the issue, we're wrapping axios and created a new http client via
axios.create()
but only applied the interceptor directly on axios lib 🤔
Copy code
ts
import axios, { AxiosRequestConfig } from 'axios';
import SuperTokens from 'supertokens-website';

SuperTokens.addAxiosInterceptors(axios);


export function useMLHttpClient() {
  const httpClient = axios.create({
    baseURL: `${process.env.VUE_APP_API_DOMAIN}`,
    timeout: process.env.VUE_APP_DEFAULT_HTTP_REQUEST_TIMEOUT,
    withCredentials: true,
  });

  function get<T>(route: string, config?: AxiosRequestConfig) {
    return httpClient.get<T>(route, config);
  }

  function post<T, D = unknown>(route: string, data?: D, config?: AxiosRequestConfig) {
    return httpClient.post<T>(route, data, config);
  }

  function put<T, D = unknown>(route: string, data?: D, config?: AxiosRequestConfig) {
    return httpClient.put<T>(route, data, config);
  }

  function del<T>(route: string, config?: AxiosRequestConfig) {
    return httpClient.delete<T>(route, config);
  }

  return {
    get,
    post,
    put,
    del,
  };
}