'laravel sanctum Route [login] not defined
I am trying to get the current user in my laravel vue application. And whenever I trie to get it i am getting this error:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined. in file C:\Users\Moeme\Documents\School\HsLeiden\Keuzevakken\IKFRAM\sla ticketsystem\ticketsystem\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php on line 444
This is what I am sending in postman:
This is what I have in my routes\api.php
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
I really do not know why it is not working
Thanks for the help
Solution 1:[1]
Add new config at headers
"Accept"=>"application/json"
Laravel will check the configuration for "Accept", it will return the web page or html if no value is set at "Accept" by default
Solution 2:[2]
Your URL incorrect. Remove "/" before query parameters.
https://127.0.0.1:8000/api/user?param1=value¶m2=value - this for route '/api/user' with query params "param1" and "param2"
You are trying pass headers in a query parameters. Move "Accept" and "Authorization" to "Headers" tab for requests in Postman.
Solution 3:[3]
I got the same error when making the request only for the postman, add this to the headers
key: Accept
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jignesh Joisar |
Solution 2 | Harmonize |
Solution 3 | Ivan Espinosa |