Currently, I am working with Angular 4's http client to communicate with a server that provides text data. To achieve this, I have implemented the following code snippet:
this.http.get('assets/a.txt').map((res:Response) =>
res.text()).subscribe((data: any) => {
console.log(data.text());
});
Surprisingly, even though I haven't specified anywhere that the response is in JSON format, I encountered the following error:
SyntaxError: Unexpected token a in JSON at position 0 at Object.parse () at XMLHttpRequest.onLoad
I find it amusing how they automatically assume the response is in JSON format :)