get-all-hubspot-companies
Version:
A demo package that allows you to retrieve all your Hubspot companies.
20 lines (16 loc) • 771 B
JavaScript
;
const { getHubspotCompanies } = require('./services');
const getAllHubspotCompanies = async (hubspotApiKey, properties = ['name', 'hubspot_owner_id', 'hs_object_id', 'master']) => {
try {
if (!hubspotApiKey) throw new Error('please provide a hubspotApiKey');
if (typeof hubspotApiKey !== 'string') throw new Error('hubspotApiKey must be a string');
if (!Array.isArray(properties) || properties.some((el) => typeof el !== 'string'))
throw new Error('properties must be an array of strings');
const companies = await getHubspotCompanies(hubspotApiKey, properties);
return companies;
} catch (error) {
console.error('error in getAllHubspotCompanies', error);
return;
}
};
module.exports = { getAllHubspotCompanies };