Looking for some assistance here. I've created an http.get method like this:
return this.http
.get(url)
.map((response: Response) => {
response = response.json(); //
console.log('The http get response', response);
return response;
})
.catch(this.handleError);
This is what the response structure appears to be:
{Body: "[{"Id":1,"Name":"Tomato Soup","Category":"Grocerie…e":"Hammer","Category":"Hardware","Price":16.99}]"}
Here's how I'm handling the subscription to the http.get method:
this.azureService.messageBody.subscribe(
(response: Response) => {
this.msgBodyDetail = JSON.parse(response.Body);
}
The variable msgBodyDetail is defined as a string type. However, I'm running into a typescript error related to response.Body:
this.msgBodyDetail = JSON.parse(response.Body);
The error is : [ts] Property 'Body' does not exist on type 'Response'.
any
Even with the error, the application seems to be functioning as expected.
console.log('Response', JSON.parse(response.Body));
Upon execution, the output is:
Response:
0 : {Id: 1, Name: "Tomato Soup", Category: "Groceries", Price: 1}
1 : {Id: 2, Name: "Yo-yo", Category: "Toys", Price: 3.75}
2 : {Id: 3, Name: "Hammer", Category: "Hardware", Price: 16.99}
Any suggestions on resolving the typescript error would be greatly appreciated.
Thank you, Lino