this.$axios is undefined inside onAuthStateChanged action
See original GitHub issueWhen using @nuxtjs/firebase and @nuxtjs/axios together, according to the documentation, we should be able to call this.$axios
in the store actions as it has been injected.
This works for all store actions except onAuthStateChanged
. I’m stuck right now because I need to fetch user info every time onAuthStateChanged
is triggerred but I can’t access my axios instance.
For example:
onAuthStateChanged({ commit, dispatch }, { authUser }) {
if (!authUser) {
commit('RESET_STORE')
return
}
commit('SET_USER', authUser)
this.$axios.get('/users/me')
}
Is this a bug ? What workarounds can we use ?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Uncaught (in promise) TypeError: Cannot read properties of ...
I think you are passing $axios as a function argument in the line below: async onAuthStateChanged({ commit, $axios }, { authUser }) {....
Read more >uncaught typeerror: cannot read properties of undefined (reading ...
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '$get') when using axios in onAuthStateChanged.
Read more >Using Firebase Authentication in a Nuxt Server-side ...
My aim for this article is to share my experience of making Firebase client-side authentication play well with the Nuxt.JS framework in a ......
Read more >[Solved]-Firebase React returns undefined on firebase ...
Coding example for the question Firebase React returns undefined on firebase. ... onAuthStateChanged((user) => { if (user) { // User is signed in, ......
Read more >Authentication with Firebase and React JS
Note: You need to have basic knowledge in React JS and hooks and ... same only differing by the buttons and the handleSubmit...
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 Free
Top 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
Still happening for me 😐️
Sure ! My bad.