I'm trying to delete a record in angular 2, the API is working fine, but when I call the method who delete, the console says:
Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response.
Of course I have been reading about the error, but the most popular solution doesn't work for me, here is the method:
deleteInventory(id){
var headers = new Headers();
headers.append('Authorization', `Bearer ${this.globalVar.getToken()}`);
headers.append("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT,
DELETE");
var options = new RequestOptions({ headers: headers });
var result = this.http.delete(this.globalVar.getHost() + "inventory/"+
id, options);
return result;
}
Can anybody help me? Thank you :D