Hi, I want to do looping of Webhook Array.
I read below article also but it is not working for me.
I am getting response like below from Webhook Output
Hi, I want to do looping of Webhook Array.
I read below article also but it is not working for me.
I am getting response like below from Webhook Output
Continuation from above.
Now when i add input in Code By Zapier, than i have to select SKU and quantity for each product. It is not coming as string for eg→ skuofproduct1, skufproduct2
I think because of i have to select each SKU, i am not able to run code by zapier action which is mentioned above.
Hey there! This will depend on the output that comes from the webhook - whether it’s fixed or variable dependent on the number of items you’re working with.
If it’s fixed like Items: Item 1, Item 2, Item 3 - You can definitely loop over it in a code step
If it’s variable like :
Item1: Item 1
Item 2: Item 2
Item 3: Item 3 etc…
Then you’ll not have a way to determine which line items to send to a code step, and yes you’re right, it won’t be possible. The way to do this instead would be to make the API call using requests in the code step - That way you can determine the length of the array and use something like map with the returned value. Some more information on this can be found here:
https://zapier.com/help/doc/how-get-started-code-zapier
https://github.com/node-fetch/node-fetch/tree/32b60634434a63865ea3f79edb33d17e40876c9f#usage
var FormData = require('form-data');
var form = new FormData();
form.append('a', 1);
fetch('http://httpbin.org/post', { method: 'POST', body: form, headers: form.getHeaders() })
.then(function(res) {
return res.json();
}).then(function(json) {
console.log(json);
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.