When I try to log in, the login method is successful, but for some reason the route push using $router
object is not working. Can someone provide assistance?
This is my code snippet:
doLogin(){
this.attemptLogin({...this.user}).then(function(){
this.$router.push('/')
} )
},
The login function works properly, however the callback this.$router.push('/')
does not execute.
The action attemptLogin
has the following code:
export const attemptLogin = ( {commit}, user) => {
return http.post('login', {
'email': user.email,
'password': user.password
}).then(response => {
return commit(types.setToken, response.data)
}).catch( e => console.log(e))
}