Interceptor not fired from created hook on full page reload
See original GitHub issueIn this standalone project https://github.com/rightaway/demo you’ll see that the I use a created
hook to make an HTTP request using this.$http.get
(https://github.com/rightaway/demo/blob/master/src/Home.vue#L11).
However, the interceptor https://github.com/rightaway/demo/blob/master/src/index.js#L16 doesn’t get fired when I load the page from a browser reload. But if I click to another link on that page (e.g. Login
) and then click back to the main link Home
, the interceptor does get fired and the console.log occurs.
Why does the interceptor not fire on initial page load?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Interceptor not executed when I refresh my page using ...
I am using JWT Authentication(Spring Boot Security) and on each click my interceptor is called to set the token before the request is...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
Once the page is loaded, the application fetches the todo items, and everything is working as expected.
Read more >How to use Axios interceptors to handle API error responses
One way to solve this problem, is to handle it when you do the request in your code, so if you have an...
Read more >Refreshing Tokens With Axios Interceptors - YouTube
Implementing JWT access and refresh token authentication with Django & React using axios interceptor method. This video is a continuation of ...
Read more >Refreshing Tokens With Fetch | Custom Interceptor - YouTube
Refresh JSON Web Tokens by building a custom wrapper around fetch calls in order to update tokens before OR after responsesSource Code: ...
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
That’s because the interceptor is added after Home component’s created() hook runs.
You can either place the interceptor before
const vm = new Vue({
or mount the vm after the interceptor:The console then shows:
@pzanitti Thanks.Your answer helps me also.