Rest(php) xmlhttprequest problem - Resolved

what is the problem ?

var body = `username=${username}&password=${password}`;
        return this.http.post(this.getMyProfileUrl,body,{method:RequestMethod.Post})
        .map(response => response.json())
        .subscribe(
           response => {
              console.log(response.uniqueID);
           }
    );

The problem is called CORS, and is in the server.

You must set headers to allow HTTP calls from different domains that is not the API domain.

You can try to add in your PhP REST function the following header and see if it works:

header('Access-Control-Allow-Origin: *');
1 Like

Thank you @Adonai, Resolved. With your reply.

1 Like