Overriding the header for wrapped baseQuery #2054
-
Hi all, I am using the a wrapped basequery to re-authenticate a user when the active token expires. However, the default baseQuery request carries a header which contains the expired token. So in the wrapped basequery my taught is to supply the if (result.error && result.error.status === 401){
const refreshResult = await baseQuery(
{url: 'auth/refresh',
headers: `Authorization Bearer ${user.refresh}` // <-- this is WRONG but I wanted to show one of my attempts
}, api, extraOptions)
if(refreshResult.data){
api.dispatch(getuser()) // <-- I am not passing any arguments to getuser() but I will.
result = await baseQuery(args, api, extraOptions)
}else{
api.dispatch(removeuser())
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
headers: {
authorization: `Bearer ${user.refresh}`
} as if you are using |
Beta Was this translation helpful? Give feedback.
as if you are using
fetch
:)