I am very new to Node.JS, can anyone help in below issue.
I am calling REST API and it is returning response body wiht JSON object. But i am not able to parse it properly.
I tried body.destination_addresses[0] to retrieve value but doesn't work.
Here is my code sample
var parsedjson=JSON.parse(body);
body.destination_addresses[0];
with parsing I am able to retrieve value of body.destination_addresses[0] but failed to retrieve "parsedjson.rows.elements[1].distance.text" value.
How can I retrieve distance value from JSON.
sample json
body:
{
"destination_addresses" : [
"458-500 St Johns Pl, Brooklyn, NY 11238, USA",
"395 4th Ave, Brooklyn, NY 11215, USA"
],
"origin_addresses" : [ "127 Tech Pl, Brooklyn, NY 11201, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "2.3 mi",
"value" : 3624
},
"duration" : {
"text" : "15 mins",
"value" : 899
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}