I am using my AngularJS code below to POST to a webhook. A POST request does go through to the webhook. However, it has no body, so none of the data is being returned.
$scope.addguest = function(guest){
//todo put guest to url
url = "https://requestb.in/18z1tu41";
item = {
'property_id':$scope.id,
'originator':guest.phone,
'guest_name':guest.name,
'check_out_date':guest.date
}
$('#exampleModalPhone').modal('hide');
$http.post(url, item, {headers: {'Content-Type': 'application/json'} }).success(function (data) {
$scope.data= data;
});
Am I missing something here with how my code is written? What is causing the POST to be empty?
This is not a CORS related issue, so not a duplicate.
$httpmakes an ajax request and sends your data in the request body and waits for the response. If the response body is empty that is an api issueFailed to load https://requestb.in/18z1tu41: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://run.plnkr.co' is therefore not allowed access.Which is a CORS problem.