fix(Typeform Trigger Node): Change output format for TypeForm trigger to object instead of array (#7315)

Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Elias Meire 2023-10-04 12:39:31 +02:00 committed by GitHub
parent 3aac22b4c1
commit b3fc00e045
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,7 +25,7 @@ export class TypeformTrigger implements INodeType {
name: 'typeformTrigger',
icon: 'file:typeform.svg',
group: ['trigger'],
version: 1,
version: [1, 1.1],
subtitle: '=Form ID: {{$parameter["formId"]}}',
description: 'Starts the workflow on a Typeform form submission',
defaults: {
@ -220,6 +220,7 @@ export class TypeformTrigger implements INodeType {
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const version = this.getNode().typeVersion;
const bodyData = this.getBodyData();
const simplifyAnswers = this.getNodeParameter('simplifyAnswers') as boolean;
@ -278,7 +279,23 @@ export class TypeformTrigger implements INodeType {
}
if (onlyAnswers) {
// Return only the answer
// Return only the answers
if (version >= 1.1) {
return {
workflowData: [
this.helpers.returnJsonArray([
answers.reduce(
(acc, answer) => {
acc[answer.field.id] = answer;
return acc;
},
{} as Record<string, ITypeformAnswer>,
),
]),
],
};
}
return {
workflowData: [this.helpers.returnJsonArray([answers as unknown as IDataObject])],
};