Problem State: I calling post request using javaScript and in response i am expecting array of dictionary in JSON Format. here is my code.
let jsonData = JSON.stringify(params)
return this.http.post(this.baseUrl, jsonData , this.options)
.map(res => res.json())
.subscribe( data => {
console.log(data);
if (data != null){
this.data = data
}else{
console.log(' Data is null')
}
},
() => console.log('Call Complete')
);
I am get this error:
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
even like that i added this header into post request.
this.myheader = new Headers({
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Headers': '*',
'Content-Type': 'application/json',
'Accept': 'application/json; charset=utf-8',
'Access-Control-Allow-Methods' : 'POST, GET, DELETE, OPTIONS, PUT',
});
How can I get rid off it.. Thanks