服务器以纯文本和有角的响应尝试解析json.如何在一个组件中解决此问题?
The server responses with plain text and angular try to parse json. How do i turn of this behaviour in one component?
get(mrn: string): Observable<string> { let url: string; url = this.Url; url = url + '?mrn=' + mrn; return this.http.get<string>(url); } download(testobject: Testobject): void { this.httpService.get(testobject.mrn) .subscribe(ccresult => { console.log('ccresult ist: ' + ccresult); }); }错误:错误:语法错误:XMLHttp上JSON.parse()位置0处的JSON中的意外令牌N ....
Error: error: SyntaxError: Unexpected token N in JSON at position 0 at JSON.parse () at XMLHttp.......
推荐答案您可以获取 HttpResponse 这样的对象:
You can get HttpResponse object like this:
this.http.get<any>(url, { observe: 'response' }).map((res): HttpResponse) => ...);