Answer the question
In order to leave comments, you need to log in
How to get a token in AdonisJs during authorization?
Good afternoon!
Understanding JWT authorization in the AdonisJs framework.
The following code should return a token:
async login({ request, auth, response }) {
try {
const data = request.all();
const { email, password } = data;
const token = await auth.attempt(email, password);
return token;
} catch(e) {
return response.status(422).send({ error: "login error" });
}
}
{
type: 'type',
token: '.....',
refreshToken: '....'
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question