Skip to content

Commit

Permalink
fix(Typeform Trigger Node): Change output format for TypeForm trigger…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
2 people authored and netroy committed Oct 4, 2023
1 parent 9fbd22e commit b1fc981
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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])],
};
Expand Down

0 comments on commit b1fc981

Please sign in to comment.