When I do a POST request using my angular app to my laravel api I get an error bad request 400 , however GET requests work normally, also I do POST requests using POSTMAN and it works , here is my code :
$http.get('http://localhost/laravel/datingApp/jobapi/public/api/user/users');
this get request works, this post request doesn't (data is an js object {'email': 'value','password': 'value'}) :
$http({
url: 'http://localhost/laravel/datingApp/jobapi/public/api/user/login',
method: 'POST',
contentType: "application/json",
data: data
}).success(function(data) {
console.log(data);
});
also I tried doing that just regular way: $http.post('blabla'); but it doesn't work either :(
edit: sorry didn't include error:
angular.js:12011 POST
http://localhost/laravel/datingApp/jobapi/public/api/user/login 400 (Bad Request)
(anonymous function) @ angular.js:12011
sendReq @ angular.js:11776
serverRequest @ angular.js:11571
processQueue @ angular.js:16383
(anonymous function) @ angular.js:16399
$eval @ angular.js:17682
$digest @ angular.js:17495
$apply @ angular.js:17790
(anonymous function) @ angular.js:25890
dispatch @ jquery.min.js:3
q.handle @ jquery.min.js:3
That was a stupid error, but thanks to @piscator I have found it, Laravel by default returns 400 when validation rules are not met , So my input was wrong all the time that is the reason I got 400.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With