一个简单的get angular4错误:预检响应中的Access-Control-Allow-Headers不允许请求头字段X-XSRF-TOKEN。
url: string = 'https://api.elasticemail.com/mailer/status/log?format=json&username=mymail@mail.com&api_key=my-key;
private readData() {
this._http.get(this.url)
.subscribe(
data => this.extractData(data),
err => this.handleError(err)
);
}
private extractData(res: Response) {
console.log("generate teste")
let body = res.json();
console.log(body);
return body.data || {};
}
如何解决这个问题?
答案 0 :(得分:0)
在Windows中,将此命令粘贴到运行窗口
中chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
this will open a new chrome browser which allow access to no 'access-control-allow-origin' header request.
参考