服务器响应纯文本和角度尝试解析json。如何在一个组件中解决此问题?
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);
});
}
错误:错误:SyntaxError:在JSON.parse()的位置0的JSON中出现意外的令牌N,位于XMLHttp .......
答案 0 :(得分:2)
你可以得到HttpResponse这样的对象:
this.http.get<any>(url, { observe: 'response' }).map((res): HttpResponse) => ...);