I got a small tweak on my code below image ., Can you give me idea how to make the domain from the API call to be dynamic. Because we plan to install the theme to another account. right now the domain is static e.g "transforminator.com" if we installed it to the different domain it simply dont work the code .. If the other account using domain e.g "testdomain.com" it should be generate the domain to that so the js code will work.
HubSpot has a number of variables available in diffrent places (e.g. templates, modules, emails, etc.). Try this:
var company_domain = "{{ company_domain }}";
Have fun
Mike
Mike EastwoodHere to learn more about HubSpot and share my HubSpot Knowledge. I'm the founder of Webalite a HubSpot Partner Agency based in Wellington, New Zealand and the founder of Portal-iQ the world's first automated HubSpot Portal Audit that helps you work smarter with HubSpot.
How do i placed that variable into the code I tried this one below but didn't work 😞
// Require axios library to make API requests
const axios = require("axios");
var company_domain = "{{company_domain}}";
// This function is executed when a request is made to the endpoint associated with this file in the serverless.json file
exports.main = async (context, sendResponse) => {
// Use axios to make a GET request to the search API
const config = {
method: "get",
url: `https://api.hubapi.com/crm/v3/objects/contacts/${context.contact.vid}/associations/deals`,
headers: {
Authorization: "Bearer pat-na1-1d1c158f-6f71-4669-b3e9-0d0fa47b89b2",
},
};
try {
const deals = [];
const { data: dealIds } = await axios(config);
for await (const dealId of dealIds.results) {
const { data: deal } = await axios.get(
`{company_domain}/_hcms/api/congratsdeal_new?id=${dealId.id}`
);
deals.push(deal);
}
console.log(company_domain)
sendResponse({ statusCode: 200, body: JSON.stringify(deals) });
} catch (error) {
sendResponse({ statusCode: 400, body: JSON.stringify(error) });
}
};