Have file for custom instance of axios in ~/plugins/axios.js
How to get access to store or router inside this file?
For example for correct handling 401-error and redirecting user to login-page with router.push of commiting mutation to store, which redirect user
P.S.: Nuxt 1.0.0-RC11
I'm trying to do this as well - use the store in axios plugin. Tried the solution above but get the error:
Cannot read property 'store' of undefined
Any help?
@tobz-nz I got the same problem, Have you solved this?
I think so...
If your in an action method then this refers to the root store, so this.$router.push(URL_URL_PATH) should work.
Thank you for your reply @tobz-nz
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
The plugin can be export a function that takes the context as an argument. See the plugins section.