I am having trouble with an ajax request to a Laravel application, specifically making a POST request to an authentication controller. I'm sending a post request with SuperAgent to a controller that uses a Request class to validate the input. The request carries a password and a username. When I inspect the console I'm getting back a GET 200 OK
and a POST 302 Not Found
. I tried debugging the application routes but nothing seemed to work.
Asked
Active
Viewed 732 times
2

Andres Zapata
- 1,710
- 1
- 16
- 32
1 Answers
3
Turns out it was something very simple. Having used jquery for a long time to make ajax request, I overlooked a very important header. The 'Accept', 'application/json'
Header. Debugging the Request validation, I noticed that Laravel's expectsJson
method was returning false, so all I had to do was add said header to the SuperAgent request object.

Andres Zapata
- 1,710
- 1
- 16
- 32