question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this.$axios is undefined inside onAuthStateChanged action

See original GitHub issue

When 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
T-Zahilcommented, Apr 2, 2021

Still happening for me 😐️

1reaction
alexisagoscommented, Apr 8, 2020

Sure ! My bad.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found