我用angular 5(最新版本)设置了一个新的应用程序,我遇到了以下错误:
Failed to set the 'responseType' property on 'XMLHttpRequest': The response type cannot be changed for synchronous requests made from a document.
如果需要我可以提供代码但是错误已经发生了:
this.http.get('https://google.com').subscribe(data => {
console.log(data);
});
用它来获取一个Observable of string
const options: { responseType: 'text'};
this.httpClient.get(url, options)
你必须为json指定类型
const options: { responseType: 'text' as 'json'};
this.httpClient.get(url, options)