AngularJS and Cross Domain POST AngularJS and Cross Domain POST angularjs angularjs

AngularJS and Cross Domain POST


You're using the $http.post incorrectly. The second parameter is the data you need to send to server, you cannot set headers like this. In your case, it will send the whole object as JSON payload

Try this:

$http({       url:'http://my.api.com/Insert',       method:"POST",       headers: {                  'Authorization': 'Basic dGVzdDp0ZXN0',                  'Content-Type': 'application/x-www-form-urlencoded'       },       data: {              'Code': 'test data'       }  });


withCredentials - {boolean} - whether to to set the withCredentials flag on the XHR object. See requests with credentials for more information.