【发布时间】:2019-11-13 12:15:20
【问题描述】:
你好,我试图在 fetchUser 方法之后获取用户名,但它变得未定义
我正在尝试这样
async loginUser() {
this.$auth.setUserToken(`${this.token}`);
this.$auth.setStrategy('local');
await this.$auth
.fetchUser()
.then(() => {
console.log(this.$auth.user); //<- this getting false i want user details
})
.catch(e => {
// console.log(e)
this.$auth.logout();
return this.$router.push(
`/${
this.$route.query.origin ? this.$route.query.origin : 'register'
}?error=1`,
);
});
},
【问题讨论】: