I am attempting to retrieve the value of "id" from a JSON response I received after making a POST request.
{
"callId": "87e90efd-eefb-456a-b77e-9cce2ed6e837",
"commandId": "NONE",
"content": [
{
"scenarioId": "SCENARIO-1",
"Channel": "Channel1-1",
"data": {
"section": {
"class": {
"repository": [
{
"export": "export-1",
"modules": "module-1",
"index": "23",
"period": {
"axis": {
"new_channel": "channel-1.1"
},
"points": [
{
"id": "6a5474cf-1a24-4e28-b9c7-6b570443df9c",
"duration": "150",
"v": 1.01,
"isNegligible": false
}
]
}
}
]
}
}
}
}
]
}
I can see the entire response json and successfully extract the value of "callId" using the code below. However, an error occurs on the last line:
Cannot read property '0' of undefined
Code snippet:
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
let responseData = JSON.stringify(body);
//Display the entire response
console.log(responseData);
//Display the callId
console.log(body['callId']);
//Error occurs here
console.log(body.content[0].repository[0].points[0].id);
}
}
Is there any solution to retrieve the value of "id"?