0

My ex-colleague left some angular.js code to save some data to database via a HTTP POST.

factory.save=function(data){
    var deferred=$q.defer();

    $http({
        url:'http://localhost/saveData',
        method:"POST",
        headers: {'Content-Type': 'application/json'},
        data:data
    }).success(function(result){
        //success
        deferred.resolve();
    });

    return deferred.promise;
}

When I exam the web traffic between the UI and API Server, I see the saveData API was called twice. The first call is using request method OPTIONS and the second one is POST as expected. I searched throughout the UI code and don't find any API call to saveData with method = OPTIONS. Is this something built in $http? How do I save this hit to the API server?

Lee
  • 2,448
  • 3
  • 22
  • 44

0 Answers0