I’m trying to create an API in Laravel, is there an api.php file in the routes folder in Laravel? or does it have to be done manually? because when I created it the file didn’t appear
I tried looking for a solution on any website but couldn’t find a way to fix it
2
Answers
You need to go to routes/api.php and write the below given code in it.
You can either call the api route by using: http://localhost:8080/api/demo OR
http://localhost/projectname/api/demo
In the routes/api.php folder the api routes are created and in the Providers/RouteServiceProvider folder it finds the default api prefix where it accesses an endpoint in the following way api/endpointexample