Angel Angel Angel Angel - 6 months ago 52
TypeScript Question

How to handle plain text, server response in Angular 2?

How to handle plain text server response in Angular 2?

I am using the following:

.subscribe(testReadme => this.testReadme = testReadme);


Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea

But I am getting a JSON format example:

{"_body":"Lorem ipsum dolor sit amet......"}

Right now I'm using something like the following to handle: (this.testReadme._boby)


This works well but is this the way to handle plain text in Angular 2 ?

Answer Source

Use response.text() method...

  .subscribe(testReadme => this.testReadme = testReadme.text());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download