Skip to main content

Hello,

I have an “id” property already in my response, under children:

 "kind": "Listing",
"data": {
"after": null,
"dist": 1,
"modhash": "",
"geo_filter": "",
"children": n
{
"kind": "t3",
"data": {
"approved_at_utc": null,
"saved": false,
"mod_reason_title": null,
"gilded": 0,
"removal_reason": null,
"link_flair_background_color": "",
"id": "pc39rj",
"is_robot_indexable": true,
}
}
],
"before": null
}
}

This is my API Endpoint Code…

return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;

// You can do any parsing you need for results here before returning them

return eresults];
});

I don’t really understand why it won’t pick it up... I am guessing I would need additional code in the parsing section?

Any help would be appreciated!

 

WDes

Hi @WDES2021 - The id needs to be at the top level, that’s why it didn’t work. Try this out and see if fixes your issue:

return z.request(options).then((response) => {
response.throwForStatus();

const results = response.json.data.children.map((child) => {
return {
...child,
id: child.data.id,
};
});

return results;
});

 


Confirmed that resolved it. Thank you for the immediate response!