We are developing a web application using AngularJS in which we want to call few rest api services from another application. It is a cross domain request, so we are not able to call it and we are getting the below error . (en.wikipedia.org/wiki/Same-origin_policy))
XMLHttpRequest cannot load http://appserver:9090/checkAndUpdate. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 400.
We are using the angular service from our typescript module (docs.angularjs.org/api/ng/service/$http) like below,
////////
static $inject = ["$http"];
constructor(private $http: ng.IHttpService) {
}
public testApi(): ng.IPromise<any> {
var baseUrl = "http://appserver:9090";
var data = {requestData};
var response = this.$http.post(url+"/checkAndUpdate", data);
return response;
}
/////
We would like to know what is the best way to achieve this by AngularJS, please direct us if there is any existing solution.
Thank you.