Capturing API results in CRM Card extensions

This is probably my limited JavaScript experience, but I can’t for the life of me get the results of API to process them in my CRM Card extension.

I have the following call:

hubspotClient.apiRequest({method: 'GET',path: /crm/v4/objects/contacts/51/associations/companies,}).then(results => {let objResult = results.body.results;console.log(the object is: ${objResult})});

The private app log console tells me that objResult is undefined. I’ve run the API call in postman, and it works. I get the following structure:

{"results": [{"toObjectId": 5188303066,"associationTypes": [{"category": "HUBSPOT_DEFINED","typeId": 1,"label": "Primary"},{"category": "HUBSPOT_DEFINED","typeId": 279,"label": null}]},{"toObjectId": 6367963345,"associationTypes": [{"category": "HUBSPOT_DEFINED","typeId": 279,"label": null}]}]}

but for the life of me, I can’t acces it within the CRM card. Execution is fine. The Private App console tells me the API call goes through.

I’m sure I’m missing something obvious …

Hey, @PAtlan :waving_hand: Are you still experiencing this issue? I noticed you resolved a similar post over the weekend. If not, I am happy to assist as needed.

Best,

Jaycee

thanks Jaycee, yes, I’m good actually - IIRC, I hadn’t understood I needed to add .json() at the end of the returned object to be able to access it …