I build a angular 4 application and back with REST API. I have send http get request to get json data using API, but I faced following error:
Failed to load http://localhost:50979/api/workflow: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
When I added headers as per the following code :
let headers = new Headers({ 'Content-Type': 'application/json',crossDomain: true});
let options = new RequestOptions({ headers: headers });
return this.http.get(this.url, options)
.subscribe(
res =>this.extractData,
err => this.handleErrorObservable
);
I have got following error :
url : string = "http://rpa.commandcenter.com/api/workflow"; let data = JSON.stringify(this.EditForm.value);
let headers = new Headers({ 'Content-Type': 'application/json',crossDomain: true});
let options = new RequestOptions({ headers: headers });
return this.http.get(this.url, options)
.subscribe(
res =>this.extractData,
err => this.handleErrorObservable
);
I can't recognize the problem.