From 5561f470e29d739cd8aec7893927a3fd4ba5506c Mon Sep 17 00:00:00 2001 From: Jonathan Bennetts Date: Tue, 12 Nov 2024 11:22:01 +0000 Subject: [PATCH] fix(Facebook Lead Ads Trigger Node): Fix issue with optional fields --- .../nodes/FacebookLeadAds/FacebookLeadAdsTrigger.node.ts | 5 ++++- .../nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/FacebookLeadAds/FacebookLeadAdsTrigger.node.ts b/packages/nodes-base/nodes/FacebookLeadAds/FacebookLeadAdsTrigger.node.ts index 5a1c06f91d..325ac81d4a 100644 --- a/packages/nodes-base/nodes/FacebookLeadAds/FacebookLeadAdsTrigger.node.ts +++ b/packages/nodes-base/nodes/FacebookLeadAds/FacebookLeadAdsTrigger.node.ts @@ -273,7 +273,10 @@ export class FacebookLeadAdsTrigger implements INodeType { return { id: lead.id, data: lead.field_data.reduce( - (acc, field) => ({ ...acc, [field.name]: field.values[0] }), + (acc, field) => ({ + ...acc, + [field.name]: field.values && field.values.length > 0 ? field.values[0] : null, + }), {}, ), form: { diff --git a/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts b/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts index a608605096..5d4950ea07 100644 --- a/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FacebookLeadAds/GenericFunctions.ts @@ -33,7 +33,7 @@ export async function facebookApiRequest( qs, body, gzip: true, - uri: `https://graph.facebook.com/v17.0${resource}`, + uri: `https://graph.facebook.com/v21.0${resource}`, json: true, }; @@ -89,7 +89,7 @@ export async function facebookAppApiRequest( method, qs, gzip: true, - uri: `https://graph.facebook.com/v17.0${resource}`, + uri: `https://graph.facebook.com/v21.0${resource}`, json: true, }; @@ -181,7 +181,7 @@ export async function facebookPageApiRequest( qs, body, gzip: true, - uri: `https://graph.facebook.com/v17.0${resource}`, + uri: `https://graph.facebook.com/v21.0${resource}`, json: true, };