2
I’m developing an api that I get the id
the user of the request through the token
, I store in my user object and I register this user. The problem is that it is not returning anything, even if I put user. If I put one console.log(user)
before the return
my object is as expected (user information that was registered + token, but the api returns Status 204 + No content.
I tried to:
const User = use("App/Models/User")
class UserController {
store ({ request, auth }){
let user = request.all()
this.usuarioLogado(auth).then(async res => {
user.user_id = res.id
user = await User.create(user)
const token = await auth.generate(user)
Object.assign(user, token)
return user
})
}
async usuarioLogado(auth) {
try {
return await auth.getUser()
} catch (error) {
console.log(error)
}
}
}
Shouldn’t be
return this.usuarioLogado(auth).then...
?– Costamilam
no, I tried that way. I had to assign the user’s return to a constant, and then return that constant.
– veroneseComS