I'm building a web application using Laravel 5.5
I created a basic user relationship system, and now I want to create a add friend
button in the user profile. I don't want to wrap this inside a form just to send a friend request, so I was thinking to make a simple AJAX post request to the server passing the logged user id and the target user id:
$.post("/request/path", { "user_1": [...] }, function () {...});
However I'm new to Laravel (and routing in general) therefore I'm not sure if I should define a route in the api.php route file and make the request to, for example, /api/friend-request
, or define a route in web.php like I did for login/register post requests. What's the proper way?