I'm using Nuxt auth-module in my project. login API returns data in this structure:
data:{
data:{
user:{
bio: null
createdAt: "2021-06-29T12:28:42.442Z"
email: "[email protected]"
id: 1
image: null
token: "token"
updatedAt: "2021-06-29T12:28:42.447Z"
username: "name"
}
}
}
and in nuxtconfig i seted module config like this:
auth: {
strategies: {
local: {
endpoints: {
login: { url: 'users/login', method: 'post', propertyName: 'data.user.token' },
user: { url: 'me', method: 'get', propertyName: 'data' },
logout: false
}
}
}
},
but token did not save in the app. any solution?
so I found a solution:
auth: {
strategies: {
local: {
token: {
property: 'user.token', // /user endpoint API returns user object
type: 'Token' // if your token type is not Bearer
},
user: {
user: 'user'
},
endpoints: {
login: { url: '/users/login', method: 'post' },
user: { url: '/user', method: 'get' },
logout: false
}
}
}
},