Angular HttpClient在Safari iOS中返回错误,但在桌面上工作

Angular HttpClient在Safari iOS中返回错误,但在桌面上工作,angular,angular5,angular-httpclient,Angular,Angular5,Angular Httpclient,我使用的是Angular 5.2.2和CLI 1.6.5,我有一个带有方法的组件 getRecentMattersForUser(userId:string){ this.matterService.getRecentMattersForUser(用户ID) .订阅(事项=>{ this.matters=matters; }, error=>this.errorMessage=JSON.stringify(错误)); } 服务 getRecentMattersForUser(userId:st

我使用的是Angular 5.2.2和CLI 1.6.5,我有一个带有方法的组件

getRecentMattersForUser(userId:string){
this.matterService.getRecentMattersForUser(用户ID)
.订阅(事项=>{
this.matters=matters;
},
error=>this.errorMessage=JSON.stringify(错误));
}
服务

getRecentMattersForUser(userId:string):可观察{
const matterService=environment.serviceBaseUrl+'/Matters?requestFor='+userId;
const headers=new-HttpHeaders({'Content-Type':'application/json'});
返回此.http.get(matterService{
事实上,
标题:标题
});
}
在我的桌面上,此列表与
*ngFor
非常重要,但在iOS上的Safari中,错误消息打印:

{“headers”:{“normalizedNames”:{},“lazyUpdate”:null,“headers”:{},“status”:0,“statusText”:“未知错误”,“url”:null,“ok”:false,“name”:“HttpErrorResponse”,“message”:“Http失败响应(未知url):0未知错误”,“错误”:{“isTrusted”:true}

有什么区别

我以前使用的是旧的
Http
(而不是
HttpClient
),就像这样

private options=new RequestOptions({'withCredentials':true});
getRecentMattersForUser(用户ID:string):可观察{
const matterService=environment.serviceBaseUrl+'/Matters?requestFor='+userId;
返回this.http.get(matterService,this.options)
.map(此.data);
}
这仍然有效


有什么想法吗?

您可能需要升级es6垫片:。此外,请检查:删除了标题设置,它也开始在Safari中工作,将不得不再次阅读文档,并查看我在以后的更新中遗漏的内容。您找到修复方法了吗?谢谢,是的,我刚刚删除了使用content-type设置标题,所以在上面的示例中:返回this.http.get(matterService,{withCredentials:true});仍然需要为http post设置内容类型如果我没记错的话,我将无法再访问该源。解决方案如下: