fix(Hubspot Node): Fix loading of Contacts (#3426)

This commit is contained in:
Michael Kret 2022-06-03 20:52:49 +03:00 committed by GitHub
parent 9bbe88f462
commit f02421b5f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -911,12 +911,16 @@ export class Hubspot implements INodeType {
const returnData: INodePropertyOptions[] = []; const returnData: INodePropertyOptions[] = [];
const endpoint = '/contacts/v1/lists/all/contacts/all'; const endpoint = '/contacts/v1/lists/all/contacts/all';
const contacts = await hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint); const contacts = await hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint);
for (const contact of contacts) { for (const contact of contacts) {
const contactName = `${contact.properties.firstname.value} ${contact.properties.lastname.value}`; const firstName = contact.properties?.firstname?.value || '';
const lastName = contact.properties?.lastname?.value || '';
const contactName = `${firstName} ${lastName}`;
const contactId = contact.vid; const contactId = contact.vid;
returnData.push({ returnData.push({
name: contactName, name: contactName,
value: contactId, value: contactId,
description: `Contact VID: ${contactId}`,
}); });
} }
return returnData.sort((a, b) => a.name < b.name ? 0 : 1); return returnData.sort((a, b) => a.name < b.name ? 0 : 1);