0
I’m trying to make a login system with Vue and firebase, but I’m having trouble redirecting the user after authentication:
login: function () {
firebase.auth().signInWithEmailAndPassword(this.email, this.password).then(
(user) => {
this.$router.push({name: 'dashboard'})
},
(err) => {
alert('Error: ' + err.message)
}
)
}
with the code this way when calling the login method I get the following error in the console:
uncaught error during route navigation:
followed by an empty red error on the console
I tried to use a self instead of this, because the first problem that came to mind was this, the result was:
login: function () {
let self = this
firebase.auth().signInWithEmailAndPassword(this.email, this.password).then(
(user) => {
self.$router.push({name: 'dashboard'})
},
(err) => {
alert('Error: ' + err.message)
}
)
}
but the error remains the same.
someone has been there?
as to the scope, the
arrow function
does not create a new scope, so your first example is correct. then I believe your problem is related to the route itself, so if possible share your routes.– Tobias Mesquita