arrays - Iterate through nested Javascript Objects from API response -
arrays - Iterate through nested Javascript Objects from API response -
i've tried 100 different things, , spend days looking through google , stackoverflow, can't find solution problem. phone call after body of api response returns undefined!
the response facebook sdk looks this:
[ { "body": "[ "data": [ { "name": "larry syid wright", "administrator": false, "id": "xxx" }, { "name": "melissa long jackson", "administrator": false, "id": "xxx" }, { "name": "charlotte masson", "administrator": false, "id": "xxx" } ], "paging": { "next": "url" } ]" },{ "body": "{ "data": [ { "id": "xxx_xxx", "message": "in honor of halloween, how many of have own ghost stories? believes in ghosts , doesn't?", "type": "status", "created_time": "2014-10-31t20:02:01+0000", "updated_time": "2014-11-01t02:52:51+0000", "likes": { "data": [ { "id": "xxx", "name": "joe herbatman owenby jr." } ], } "paging": { "cursors": { "after": "xxx", "before": "xxx" } } } },{ "id": "xxx_xxx", "from": { "id": "xxx", "name": "jessica starling" }, "message": "watching "campaign" , can't help notice fantastic job did (will ferrell , all) north carolina accent! ya'll know sound different other southern states ;)", "type": "status", "created_time": "2014-11-01t02:36:21+0000", "updated_time": "2014-11-01t02:36:21+0000", "likes": { "data": [ { "id": "xxx", "name": "scott williams"n } ] } } ], "paging": { "previous": "xxx", "next": "xxx" } }" } ]
this response batch call. if phone call them separately, can iterate through responses, , them. when phone call them in batch though, can't past "body", , need utilize batch call.
console.log(response[0].body);
homecoming object within body of first part of response, console.log(response[0].body.data);
returns undefined. don't it. should simple it's there's lock on door , don't have right key.
i have no issue iterating through objects, don't need generalized answer. need help seeing whatever here don't see. why console show undefined when phone call after body, , need doing of these values?
that json contains nested json. body seems string. use
var body = json.parse(response[0].body);
javascript arrays object javascript-objects facebook-sdk-4.0
Comments
Post a Comment