I'm trying to create an integration using a Rest API. Afaik the way to do this is using a webhook.
However, for every API that I test the webhook always returns only the first item in the array.
Is there a way to return all items in the array?
Best answer
Webhook 'Get' request always returns just the firsts item in an array
Best answer by Troy TessaloneBest answer by Troy Tessalone
ChatGPT produced this Zap Code step JavaScript to use.
https://zapier.com/apps/code/help

let url = inputData.Endpoint;
async function perform(inputData) {
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
// Add authentication if needed: 'Authorization': `Bearer ${inputData.api_key}`
}
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const rawJson = await response.text(); // Get raw response as text
let parsedData;
try {
parsedData = JSON.parse(rawJson); // Attempt to parse JSON
} catch (parseError) {
parsedData = null; // If parsing fails, return raw JSON only
}
return {
parsedData, // Parsed JSON object (if valid)
rawJson // Raw JSON response as a string
};
} catch (error) {
return { error: error.message };
}
}
return perform(inputData);
OUTPUT

Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.