What we need to do:
Foreach Line item in order do a lookup in table to find matching rows and return that rows as result
When we do a test run we receive following output:
ID
AD5l9WavzQVmPkPbzEhp8B7baTLu129E
runtime_meta
Runtime Meta Memory Used Mb
77
Runtime Meta Duration Ms
392
Runtime Meta Logs
Runtime Meta Async
true
The code used is :
const nameToLookup = inputData.Name;
async function repeat(nameToLookup) {
const result = l]
nameToLookup.split(",").forEach(function (item) {
const response = fetch(`https://api.zapier.com/v1/tables/01J6VZ03B4FTXXN29VTZTHW9P8/rows?filteriProduct]=${encodeURIComponent(item)}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${process.env.ZAPIER_API_KEY}`,
'Content-Type': 'application/json'
}
}).then(
data => {
result.push(data.json())
}
)
});
return result;
}
const data = await repeat(nameToLookup);
output = data.length > 0 ? data 0] : {};