Skip to content
Advertisement

I can’t get JWT token in Laravel

I am creating an API in Laravel 8 (PHP 7.4) and I wanted to secure it. The choice fell on tymon / jwt-auth. I follow the documentation from the website: https://jwt-auth.readthedocs.io/en/develop/quick-start/

Everything works fine here. However, later when I create a route to login and want to get the token using auth()->attempt(), I have the following error:

Undefined method ‘attempt’.

My Route code:

JavaScript

auth.php:

JavaScript

What’s wrong?

Advertisement

Answer

You can try this line

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement