I'm trying to combine data from two Hubspot API calls and show the combined dataset in the UI in a table.
The first API call is to Hubspot's 'deals' endpoint and returns data about a specific deal -- including the 'line items' that are associated with the deal
{
"id": "123456789",
"properties": {
"amount": "200000",
"closedate": "2024-04-04T14:39:31.927Z",
"createdate": "2024-02-19T15:39:32.414Z",
"deal_currency_code": "GBP",
"dealname": "Master Service Agreement",
"dealstage": "13166030",
"hs_lastmodifieddate": "2024-06-19T15:32:00.416Z",
"hs_object_id": "123456789",
"hubspot_owner_id": "16553728",
"net_terms": "30",
"pipeline": "13166025",
"renewal_factor": "10"
},
"createdAt": "2024-02-19T15:39:32.414Z",
"updatedAt": "2024-06-19T15:32:00.416Z",
"archived": false,
"associations": {
"companies": {
"results": [
{
"id": "20071824689",
"type": "deal_to_company"
},
{
"id": "20071824689",
"type": "deal_to_company_unlabeled"
}
]
},
"line items": {
"results": [
{
"id": "9558991966",
"type": "deal_to_line_item"
},
{
"id": "9558991967",
"type": "deal_to_line_item"
},
{
"id": "9558991968",
"type": "deal_to_line_item"
},
{
"id": "9558991969",
"type": "deal_to_line_item"
},
{
"id": "9558991970",
"type": "deal_to_line_item"
},
{
"id": "9558991971",
"type": "deal_to_line_item"
},
{
"id": "9558991972",
"type": "deal_to_line_item"
},
{
"id": "9570796573",
"type": "deal_to_line_item"
},
{
"id": "9570800800",
"type": "deal_to_line_item"
},
{
"id": "9570800801",
"type": "deal_to_line_item"
}
]
},
"contacts": {
"results": [
{
"id": "17873686199",
"type": "deal_to_contact"
},
{
"id": "17873686199",
"type": "legal_signatory"
}
]
}
}
}
The second API call is to Hubspot's 'line items' endpoint and returns data about a specific line item,
{
"id": "9558991966",
"properties": {
"amount": "15000.00",
"createdate": "2024-06-03T13:45:52.085Z",
"hs_lastmodifieddate": "2024-06-05T11:58:49.073Z",
"hs_object_id": "9558991966",
"hs_product_id": "1409599372",
"name": "12 Month Subscription",
"quantity": "1",
"recurringbillingfrequency": "annually"
},
"createdAt": "2024-06-03T13:45:52.085Z",
"updatedAt": "2024-06-05T11:58:49.073Z",
"archived": false
}
I have the line item data returned from the deals endpoint in a table,
But what i'm aiming for us to call the line items endpoint for each table row in order to get the data to achieve something like this,
I've spent all day yesterday trying to figure this out myself and got lost in the world of javascript queries, for loops, promises, maps, async etc so any help on this would be greatly appreciated.
Thanks!