$http triggered twice

This is my code

$scope.login = function(email,password){
$http({
method: ‘POST’,
url: ‘http://localhost:3000/api/login’,
headers: {
‘owner’: $rootScope.secret
},
data: {email:email, password:password }
}).then(function successCallback(response) {
console.log(response.data)
}, function errorCallback(response) {
console.log(response.data)
});
}

But in my network tab I’m seeing 2 request, one is by ionic :slightly_smiling:

The second one is my POST request, I wonder why there’s one OPTION method up there.

The Option request method performs a preflight request to http://localhost:3000/api/login and includes the Origin and Access-Control-Request-Method headers with the appropriate values.
This is normal, don’t worry about it.

1 Like