Reputation: 514
I have a problem with Angular 2 http.delete
method. My code is below:
const headers = new Headers({'Content-Type': 'application/x-www-form-urlencoded'});
this.http.delete(ConstVarService.url + 'api/tasks/UsunZapis', new RequestOptions({
headers: headers,
body: {tasksId: entryId}
})).subscribe((data) => {
console.log(data)
});
And when I execute, I gets the following errors:
OPTIONS http://192.168.13.36/pplus-dev/appapi/api/tasks/UsunZapis 405 (Method Not Allowed)
Failed to load http://192.168.13.36/pplus-dev/appapi/api/tasks/UsunZapis: Response for preflight has invalid HTTP status code 405
But in Postman everything works, the same URL, Content-Type etc.
Upvotes: 0
Views: 1243
Reputation: 9301
In order to make a request that is cross-domain the browser does what is called a pre-flight check. You need to return the appropriate CORS headers in order to allow the browser to make requests.
Upvotes: 1