question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How implement AxiosAuthRefreshRequestConfig type

See original GitHub issue

I have this instance

export const aInstance = axios.create({
  baseURL: API_URL,
  headers: { 'Content-type': 'application/json' },
})

and use with your config:

createAuthRefreshInterceptor(aInstance, refreshAuthLogic, { statusCodes: [401, 403] })

But if i want add the flag to skip refresh token with Typescript, for example

export const login = (data: LoginDataType): Promise<AxiosResponse> => {
  const url = '/auth/login'
  return aInstance.post(url, data, { skipAuthRefresh: true })
}

On { skipAuthRefresh: true } TypeScript said:

Argument of type '{ skipAuthRefresh: boolean; }' is not assignable to parameter of type 'AxiosRequestConfig'.
  Object literal may only specify known properties, and 'skipAuthRefresh' does not exist in type 'AxiosRequestConfig'

It can fix with your AxiosAuthRefreshRequestConfig, but how can i implement it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Flyrellcommented, Jun 24, 2021

Unfortunately, the only way is to cast it with as.

axios.post(url, data, { skipAuthRefresh: true } as AxiosAuthRefreshRequestConfig);
1reaction
Flyrellcommented, Jun 25, 2021

Hah, that’s something new. I think it might be the set up on your side, as it work just fine at my end, but try wrapping it up in () or using the other casting syntax…

axios.post(url, data, <AxiosAuthRefreshRequestConfig>{ skipAuthRefresh: true })
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple requests,about Flyrell/axios-auth-refresh - GithubHelp
Please, use StackOverflow for implementation questions. ... Specify a different type HOT 1; How implement AxiosAuthRefreshRequestConfig type HOT 6 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found