Error while trying to post data into my local server


I created a sample registration form and tried to insert data into local database ( am using php for server side ) but i got the following error

XMLHttpRequest cannot load http://localhost/manager/managerApi.php?key=register. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.

ERROR Error: Uncaught (in promise): Response with status: 0  for URL: null

Find below my code that i wrote in the provider :

postData(data,key) {

    return new Promise((resolve,reject) => {

      let headers = new Headers();,JSON.stringify(data),{headers:headers}).subscribe(res => {

      },(err) => {






The error message is quite clear: Your response needs that header.



Yes, that was the issue. I found it. Anyway thanks for your help


So how did you fix it?


Added these in my api

    header('Access-Control-Allow-Origin: *');
	header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
	header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");