Get deal associated company properties

Hello,

my requirement is to get a few of the deal-associated company properties in a callback function whose values would be used in the next action of workflow. I have developed half of the code but couldn’t complete it. It would be helpful if anyone could assist with this.

Code:

exports.main = async (event, callback) => {
const hubspotClient = new hubspot.Client({
apiKey: process.env.HAPIKEY_APP
});

var options = {
method: ‘GET’,
url: ‘https://api.hubapi.com/crm/v3/objects/deals/‘+event.inputFields[‘hs_object_id’]+’/associations/company?limit=500’,
headers: {
‘Authorization’: ‘Bearer pat-na1-YOUR-TOKEN’,
‘Content-Type’: ‘application/json’
},
body: JSON.stringify({
//write code?
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log("STATUS: " +response.statusCode);
console.log("HEADERS: " +JSON.stringify(response.headers));
console.log("BODY: " +response.body);

var parseBody = JSON.parse(response.body);
var keysArray = Object.keys(parseBody);

callback({
outputFields: {
//??? what to write
}
})
});
}

Hi, @S_Tasneem :waving_hand: I edited your post to remove your token details. Please be mindful to not include private information in your posts.

When you say you are getting stuck, can you share more details? Rather than asking the community to write code for you, including what you’ve tried, even if it isn’t working as expected, is helpful. My experience is that the community is likely to be able to spot an error or troubleshoot a code block rather than providing custom code itself.

Thank you! — Jaycee