How to eject manually
See original GitHub issueThe documentation doesn’t say how to combine
axios-auth-refresh and custom error interceptors.
There is only the line “interceptor id (in case you want to eject it manually)”
How to eject it manually?
When i use $axios.onError
(from @nuxt/axios) with createAuthRefreshInterceptor
it stop working.
Code in nuxtjs plugin file:
import createAuthRefreshInterceptor from 'axios-auth-refresh';
import { Api } from '@/api/api'; // Custom api layer
export default function({ $axios, store, isServer, res, error }, inject) {
$axios.onError(async errorObject => {
const code = parseInt(errorObject.response && errorObject.response.status);
let message = '';
if (code === 404) {
message = 'Page not found';
}
if (code === 422) {
return { error: errorObject, data: errorObject.response.data };
}
... // other codes
error({ statusCode: code, message });
return { error: errorObject, data: errorObject.response.data };
});
const refreshAuthLogic = failedRequest =>
store.dispatch('global/refreshToken').then(tokenRefreshResponse => {
failedRequest.response.config.headers['Authorization'] =
'Bearer ' + tokenRefreshResponse.token;
return Promise.resolve();
});
createAuthRefreshInterceptor($axios, refreshAuthLogic);
const api = new Api($axios);
inject('api', api);
}
And it doesn’t work, but if remove the onError handler it will
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to eject a stuck disc from a PS4 console (US) - PlayStation
If a disc gets stuck in your PS4 console, you can manually eject it. Before you begin you need: A long Phillips screwdriver;...
Read more >How to manually eject a stuck PS4 game - Asurion
Insert a screwdriver into the manual eject hole, just above the PS4 logo, and turn counterclockwise to release the disc. You'll have to...
Read more >How to Manually Eject a Stuck Disc in a PlayStation 4 - iFixit
Use a Phillips screwdriver and rotate the screw counter-clockwise. This shouldn't require very much pressure and you should see the stuck disc slowly...
Read more >How to manually eject the CD/DVD drive tray. | Sony USA
To manually eject the CD/DVD drive tray from a Sony® CD/DVD drive, insert a pointed object, such as a paper clip, into the...
Read more >8 Ways to Force Eject a Disc from Your Mac's Optical Drive
Hold down the eject key; Drag the disc icon to your Mac's trash bin; Right-click on the disc icon and select eject; Press...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, if you emit it manually, you woudn’t really need that library. But there’s a bit more logic for it to work properly, as you need a queue for requests that has been dispatched while the token is refreshing, etc.
I think it might work if you move the
createAuthRefreshInterceptor
above theonError
(so it gets called after your own$axios.onError
interceptor and instead of returningPromise.reject({ error: errorObject, data: errorObject.response.data })
you’d return thePromise.reject(errorObject);
. Can you try that?I’m not exactly sure what you’re trying to achieve. Would you please edit your question with a code sample?
Manual ejection should be as simple as calling the following…