So i'm working on a hubspot api that returns back all contacts as a POC. The api is working an all contacts are returned, but as you can imagine I can't push it to a json table because of the expected format. I've tried various methods to get a flattened json object, but I can't get them to work in appsmith.
Here is the code i've attempted:
const contacts = {
"contacts": [
{
"portal-id": 23267257,
"is-contact": true,
"properties": {
"firstname": {
"value": "Maria"
},
"lastmodifieddate": {
"value": "1669311480457"
},
"company": {
"value": "HubSpot"
},
"lastname": {
"value": "Johnson (Sample Contact)"
}
},
ACTUAL CODE
getting res.map not a function error, or Cannot read properties of undefined (reading 'find') when I attempt to convert this into an object, then map.
const flatContacts = [];
Object.values(res).map(contact => {
flatContacts.push({
firstname: contact.properties?.firstname?.value,
lastname: contact.properties?.lastname?.value,
email: contact.identities.find(identity => identity.type === 'EMAIL')?.value
});
});
what am i missing