I create Laravel+Vue simple REST API web-app.
In Vue component I have a method with an api request.
I simplified this to see the core of the problem:
phpValidate() {
axios
.post("api/validate", self.programmer)
.then(function(response) {
console.log(response.status);
});
}
In the controller I have a method validateIt()
, which handle this "api/validate"
request.
It returns:
return array('status' => $status, 'data' => $data);
The $status
can be equal to 200 or 422, depends on the input data.
The problem is that from some point, it began to return $status
of 200 always.
Even if I delete all the code from the method validateIt()
and just leave two lines:
$status = 422;
return array('status' => $status);
I still receive 200. If I delete the whole method in controller, it gives an error 404.
So, the route and function name is correct. When I put it back, I can write there whatever I like, it doesn't have any sence - it still returns 200!
If I use debugger, I can see that at the end of validateIt()
method it returns 422.
But, when I get the response in phpValidate()
I see again 200.
Unbelievable!
I tried:
npm run dev
and
php artisan cache:clear
doesn't help!
Also I tried to restart the server and use different browsers, doesn't help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire