fix(Facebook Lead Ads Trigger Node): Fix issue with optional fields

This commit is contained in:
Jonathan Bennetts 2024-11-12 11:22:01 +00:00
parent c08d23c00f
commit 5561f470e2
No known key found for this signature in database
2 changed files with 7 additions and 4 deletions

View file

@ -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: {

View file

@ -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,
};