Angular关闭JSON解析器 [英] Angular turn off json parser
本文介绍了Angular关闭JSON解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
服务器以纯文本和有角的响应尝试解析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) => ...);
这篇关于Angular关闭JSON解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文