I have a local Angular4
application that's trying to post to a local django server. The problem is that I'm getting an error in the http.post()
, but I don't think it's caused by an issue with the CORS
(I'm managing to consume this api using an android app, and I don't see any error message in the Angular-app about the Access-Control-Allow-Origin
). Please find below my code:
// get token from the server
const body = {
username: 'username',
password: 'password'
};
this.http.post('http://website.loc/api/auth/login/', body).subscribe(
res => {
console.log('res:' + res);
},
(err: HttpErrorResponse) => {
console.log('err');
console.dir(err);
}
);
Here is the error I'm getting (it seems that it's not able to read the url):
{headers: Object, status: 0, statusText: "Unknown Error", url: null, ok: false, name: "HttpErrorResponse", message: "Http failure response for (unknown url): 0 Unknown Error", error: ProgressEvent error}
Any clue what might cause these kind of issues?