0
I nuxtjsを使用しています、私は彼がLOGGEDIN後にユーザーをリダイレクトする、リダイレクト()メソッドは、私の関数内で動作していない:fetchメソッドではなくコンポーネントメソッドでnuxtjsでリダイレクトを行う方法は?
loginUser: function() {
if (this.isValid) {
return axios.post(`/user/login`, {email: this.login.email, password: this.login.password})
.then((res) => {
let response = res.data
if (typeof response.token !== 'undefined') {
setToken(response.token)
window.location.href = '/'
}
}).catch((e) => {
console.log(e.message)
})
}
}
はまた、これがために働い
loginUser: function() {
if (this.isValid) {
return axios.post(`/user/login`, {email: this.login.email, password: this.login.password})
.then((res) => {
let response = res.data
if (typeof response.token !== 'undefined') {
console.log('loggedin')
this.props.url.replace('/')
}
}).catch((e) => {
console.log(e.message)
})
}
}