You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, im using React 18 and axios 1.4.0
This is how I define the axios instance (following the tutorial)
const BASE_URL = 'http://localhost:8080/api'
// 1. Create an axios instance that you wish to apply the interceptor to
export const apiAuthInstance = axios.create({ baseURL: BASE_URL })
// 2. Define token refresh function.
const requestRefresh: TokenRefreshRequest = async (refreshToken: string): Promise<IAuthTokens | string> => {
const response = await axios.post(`${BASE_URL}/auth/refresh_token`, { token: refreshToken })
return response.data.access_token
}
// 3. Add interceptor to your axios instance
applyAuthTokenInterceptor(apiAuthInstance, { requestRefresh })
// If applyAuthTokenInterceptor is applied, then I cant make any api calls at all
// Here "/asd" wont be called, or any other place it just doesnt make the call.
// What am I doing wrong?
apiAuthInstance.post("/asd")
The text was updated successfully, but these errors were encountered:
Im getting an error in console: Unable to refresh access token for request due to token refresh error: Invalid token specified: undefined
Howerver, if I manually call:
Hello, im using React 18 and axios 1.4.0
This is how I define the axios instance (following the tutorial)
The text was updated successfully, but these errors were encountered: