Ok I’m having a brain fart. I need to pull out the value for "data" as described below…
(UPDATED:) console.log(d.body) gives me...
{
"data": [{
"id": "30220059",
"login": "esl_sc2",
"display_name": "ESL_SC2",
"type": "",
"broadcaster_type": "partner",
"description": "For standings, schedule, and results, visit https://pro.eslgaming.com/tour/sc2/",
"profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/cac110f7-0711-421f-9341-c77b53ab63b5-profile_image-300x300.jpeg",
"offline_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/ac0e240d-63c2-4faf-9040-60543b3e2c0f-channel_offline_image-1920x1080.jpeg",
"view_count": 0,
"created_at": "2012-05-02T09:59:20Z"
}]
}
What do I need to do on d.body
to get the output to look like this?
{
"id": "30220059",
"login": "esl_sc2",
"display_name": "ESL_SC2",
"type": "",
"broadcaster_type": "partner",
"description": "For standings, schedule, and results, visit https://pro.eslgaming.com/tour/sc2/",
"profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/cac110f7-0711-421f-9341-c77b53ab63b5-profile_image-300x300.jpeg",
"offline_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/ac0e240d-63c2-4faf-9040-60543b3e2c0f-channel_offline_image-1920x1080.jpeg",
"view_count": 0,
"created_at": "2012-05-02T09:59:20Z"
}
I thought it was simply d.body.data[0]
?
2
Answers
Turns out typeof d.body is my friend here. It was returning a string not an object.
you can get direct the json using the following Destructuring assignment
Destructuring assignment