But Zapier throws an error saying it needs an array of objects, not the object I’m returning. The error shows the exact object structure but says it’s not in the right format. I thought I was returning the correct data type but apparently not. What am I missing here?
yeah, classic zapier gotcha. your api’s returning an object but zapier polling triggers need arrays. quick fix: wrap it in Object.values() like return Object.values(data.reservations). just heads up - you’ll lose the reservation ID unless you merge it back in.
I hit the same issue building my first Zapier integration. Zapier triggers need arrays, but your API sends back reservations as an object with numeric keys. You need to transform that object into an array format. Here’s how you can flatten it and add the reservation ID to each item: javascript return z.request(requestConfig) .then((response) => { response.throwForStatus(); const data = z.JSON.parse(response.content); const reservationsArray = Object.entries(data.reservations).map(([id, reservation]) => ({ reservation_id: id, title: reservation.details.title, scheduled_date: reservation.details.scheduled_date })); return reservationsArray; }); This flattens your nested structure and makes it way easier to work with in Zapier. Object.entries is perfect when you need both the key and value from your original object.
Zapier needs an array for triggers, but you’re sending an object with reservation IDs as keys. Your API returns reservations as an object (with keys like 78), not an array.
You need to convert that object to an array. Here’s how to fix your return statement: