I am trying to wrap my head around the use cases of web routes and api routes.
So far, from what i understand
Web routes, are used when we want to return views.
Api routes, are used when we want to return json ( Api resource/collection ).
However both of these cases are referring to GET requests.
What about when we make a POST or PUT request, do we put these routes in api.php or web.php. Does it depend on whether the request is through an AJAX call ?
Additionally, i can't figure out in what cases should we use the api middleware and web middleware By default, the web.php uses web middleware, whereas the api.php uses the api middleware.
In the case where we are already signed in and we want to make an AJAX call, do we have to put that route in the api.php or web.php.
Do we use the api middleware only when we sign in using token based authentication ?