How to discard preflight response in AngularJS

Viewed 332

When sending a http.post request to my service I initially send an Option request (as required by Cors).

However I've realized that my OPTIONS (pre-flight) request is returning no response.data in its response, but my POST request is. This poses a problem as I need to access the response.data from the POST response...

Does Angular allow us to somehow discard the OPTIONS response in a http.post call?

$http.post("http://api.worksiteclouddev.com/RestfulAPI/api/vw_PeopleListSiteAccess_Update/Get/", JSON.stringify(vm.content))
    .then(function (response) {
        //success

        vm.person = {
            "firstname": response.data.Firstname,
            "surname": response.data.surname
        }; 
        console.log(response.data);
    },
    function (error) {
        //failure
        console.log("Something went wrong..." + error.status);
    })
    .finally(function () {
        vm.ptsnumber = "";
    });

Chrome responses: enter image description here

1 Answers
Related