Issue With HttpClient Post


#1

Hello there,

I’m new to Ionic, but I’m working my way through it. I have a web api in the cloud that I have setup CORS on. I can test this from my local computer (localhost) and it posts to the web api without an issue.

When I try and do this in my .ts file, I get the following error:

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access. The response had HTTP status code 500.

Here is the data that I’m posting:

this.http.post(apiUrl, JSON.stringify(data), {headers: {‘Content-Type’: ‘application/json’}})
.subscribe(data => {
console.log(‘Should be good’ + data)
}, error => console.log(error));

Any help would greatly be appreciated.


#2

I was able to resolve the issue.