I was trying below code,where body is response from HTTP GET. When I tried to run it, I am getting below error.
Cannot read property '
po_number' of undefined
{
"d": {
"results": [
{
"po_number": "PO1001",
"product_id": "PD1001",
"message": "Exists",
"timestamp": "2016-05-01"
}
]
}
}
How to access po_number
var profile = JSON.parse(body);
console.log("profile: "+ profile.results.po_number);
I am getting undefined when i access above code
profile.resultsit's an array not an object, you have to use something likeprofile.results[index].po_number,profile.results[0].po_numberfor example.