Error 500 when performing an authentication request with AdonisJs

0

I have a SessionController, which is the method that performs the user authentication process in the application.

class SessionController {
  async store ({ request, response, auth }) {
    const data = request.all()
    const token = await auth.attemp(data.email, data.password)
    return token
  }
}

My routes.js, I also have the instance of this method for mapping the API:

Route.post('/sessions', 'SessionController.store')

The user data, already in the database, the problem is that when I make the request, I get a 500 error.

I debugged the application, and it seems that the application does not run after the const token = await auth.attemp(data.email, data.password) line.

No idea what it can be!

    
asked by anonymous 03.12.2018 / 00:33

1 answer

1

Because the status of the code is 500, it is probably an error in the code, see:

You have written the attempt method incorrectly. In your code, there is this excerpt:

  

const token = await auth.attemp(data.email, data.password)

According to documentation , the correct one is:

const token = await auth.attemp(data.email, data.password)
    
03.12.2018 / 00:36