我正在尝试在axios中使用nuxt-auth模块,它给出了“无法读取未定义的”...and登录头的属性‘数据’的奇怪路径"Request URL:http://aqar.abdullah.link/api/api/auth/login",有什么帮助吗?
Nuxt.config.js
axios: {
baseURL:'http://aqar.abdullah.link/api',
auth: {
strategies: {
local: {
endpoints: {
login: { url: '/office/login', method: 'post', propertyName: 'data.token' },
user: { url: '/auth/me', method: 'post', propertyName: false },
logout: false
}
}
}
}}
登录方式:
methods:{
async Login(){
try{
await this.$auth.loginWith('local', {
data:{
email: this.email,
password: this.password
}
})
this.$router.push('/')
}catch(e){
this.error = e.response.data
}
},
},发布于 2020-05-08 20:18:04
我不确定,我使用了完全相同的配置,它对我有效。但是您的nuxt.config.js文件缺少axios对象的结束},。
它应该看起来像这样:
axios: {
baseURL: "http://aqar.abdullah.link/api"
},
auth: {
strategies: {
local: {
endpoints: {
login: {
url: "/office/login",
method: "post",
propertyName: "data.token"
},
user: { url: "/auth/me", method: "post", propertyName: false },
logout: false
}
}
}
},还要确保你的nuxt.config.js中也有这些模块:
modules: [
"@nuxt/http",
"@nuxtjs/auth",
"@nuxtjs/axios",
],https://stackoverflow.com/questions/61655996
复制相似问题