Title: nuxt-auth setting user object after login
Tags: authentication;nuxt.js
Question: im using the nuxt-auth module.
I've got it to work so far. I am able to login properly.
But whenever i login, the user object in my store does not get set.
It seems like my API is getting called without parameters so it does not know which user to set.
nuxt.config.js
auth: {
redirect: {
login: '/login',
logout: '/login',
callback: '/login',
home: '/'
},
strategies: {
local: {
endpoints: {
login: {
url: 'token',
method: 'post',
propertyName: 'token'
},
user: {
url: 'microservice/user',
method: 'get',
propertyName: false
},
logout: false
}
},
watchLoggedIn: true,
resetOnError: true
logging in
await this.$auth.loginWith('local', {
data: {
username: this.username,
password: this.passwort
}
})
example API-User
"method": "GET",
"path": "/user/102",
"query": "",
"response": {
"type": "single",
"payload": {
"id": 102,
"firstname": "super",
"name": "test",
"username": "stest1",
//some data
After retrieving a token and setting it, my app sends a request without query/parameters to my user-API. Either im doing something wrong, or am just too dumb too see the right way to set my user. However, if i set my user-Route to for example 'microservice/user/102' it is able to retrieve that one specific user.
Hoping anyone can help! :D


Here is another answer: I think you should set it propertyName for user endpoint
user: {
url: 'microservice/user',
method: 'get',
propertyName: payload

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:04/18/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<authentication><nuxt.js>', 'Title': 'nuxt-auth setting user object after login', 'ViewCount': 1847, 'id': 55741813, 'user_AboutMe': None, 'user_AccountId': 15657205.0, 'user_DisplayName': 'Kevin', 'user_Reputation': 21.0, 'user_Views': 21.0, 'user_id': 11297224.0}}