0

I'm trying to get the POST error response in $http AngularJS, but when I watch the response variable in catch, I get the preflight OPTION response. How can I get the POST response, instead of OPTION?

My OPTION returns 200 OK and my POST returns 402. But my reason.data is null

Thanks in advance

$http.post(url, data, {headers:{}})
.then( function ( response ) {})
.catch( function ( reason ) {
    console.log(reason);
});

---EDIT---

Actually the POST response seems OK, but my reason returns status: -1 and data: null

2
  • If the OPTIONS request is failing and hitting the catch block then the POST will not be performed. Commented Oct 8, 2019 at 22:25
  • With pre-flight OPTION requests, the browser never passes the OPTION response to JavaScript. If the OPTION request fails, the browser will block the POST request. The AngularJS $http service returns a status of -1. All responses are blocked from JavaScript. Commented Oct 8, 2019 at 22:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.