I'm using Angular 5.2.2 and CLI 1.6.5, I have a component with method
getRecentMattersForUser(userId: string) {
this.matterService.getRecentMattersForUser(userId)
.subscribe(matters => {
this.matters = matters;
},
error => this.errorMessage = JSON.stringify(error));
}
Service
getRecentMattersForUser(userId: string): Observable<Matter[]> {
const matterService = environment.serviceBaseUrl + '/Matters?requestFor=' + userId;
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
return this.http.get<Matter[]>(matterService, {
withCredentials: true,
headers: headers
});
}
On my desktop this lists matters nicely with an *ngFor
but in Safari on iOS errorMessage prints:
{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":null,"ok":false,"name":"HttpErrorResponse","message":"Http failure response for (unknown url): 0 Unknown Error","error":{"isTrusted":true}}
What's the difference?
I used to use the old Http
(instead of HttpClient
) like so
private options = new RequestOptions({ 'withCredentials': true });
getRecentMattersForUser(userId: string): Observable<any> {
const matterService = environment.serviceBaseUrl + '/Matters?requestFor=' + userId;
return this.http.get(matterService, this.options)
.map(this.extractData);
}
Which still works.
Any ideas?