Skip to main content

Is there a way to handle outputFields dynamically? I tried to do it this way, but it didn't work:

 

const outputFields = [];const perform = (z, bundle) => {    return [bundle.cleanedRequest];};const performList = (z, bundle) => {    const options = {        url: 'https://webhook_url',        method: 'post',        hook_id: {            'Authorization': 'Bearer ' + bundle.authData.access_token,        },        body: {},    };    // This part will be generated through a mapping in JSON    outputFields.push({        key: 'form',        label: 'Form',        type: 'string',    })    return z.request(options).then((response) => {        return response.data    });};

Sorry I forgot to format the code, here is the properly formatted code:

const outputFields = [];
const perform = (z, bundle) => {
return [bundle.cleanedRequest];
};

const performList = (z, bundle) => {
const options = {
url: 'https://webhookurl',
method: 'post',
headers: {
'Authorization': 'Bearer ' + bundle.authData.access_token,
},
body: {
form_id: bundle.inputData.form_id,
},
};

// Here I'm using a simple value, but I plan to do it by mapping the JSON
outputFields.push({
key: 'form',
label: 'Form',
type: 'string',
})

return z.request(options).then((response) => {
return response.data
});
};