#Mapping object to table

1 messages · Page 1 of 1 (latest)

lunar shuttle
#

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

wide marshBOT
#

Hey There,

We've registered your query, and our team will get back to you soon.

Regards,
Pranav

wide marshBOT
#

Hi there!
Can you share the response you're getting back from the API (or a sample that
has the same exact structure)?

pearl torrent
lunar shuttle
#

Thank you, I will play with this. For now I was able to get this working with following map schema. I think i'll have to assign and omit the identity-profiles object since hubspot returns it in a way that would show as duplicate identities.type when trying to merge into a table. I think at this point i'm out of your scope since it's coding vs your app, so thank you for getting me this far. The only appsmith doubt I have is here you can see the object structure includes contacts.identify-profiles but appsmith is treating the -profiles as not defined. Is this a limitation, or something that i'm missing @pearl torrent

pearl torrent