Hi there,
Â
I’m using a Schedule by Zapier zap, that triggers every day, and uses Code by Zapier to fetch data from an Airtable using a Fetch request and then trigger another webhook to send a SMS message for each row.
Â
When testing the Code by Zapier part, the webhook gets called and the SMS is being sent, but when running automatically through the scheduler, the API part gets the data but the other zap which is triggered by a webhook doesn’t fire.
Â
Here’s the code:
var settings = {
 'method': 'GET',
 'headers': {
  "Authorization": "Bearer ...",
 },
};
fetch('https://api.airtable.com/...', settings)
.then(function(res) {
 return res.text();
})
.then(function(body) { Â // body is the raw return from the API call
 body.toString();
  var jsonData = JSON.parse(body);
  var length = jsonData.length;
  var output = r];
   for (let i = 0; i < jsonData.records.length; i++){   // This for loop processes each record and adds it to the array
    output.push(jsonData.records i].fields);
   }
   return body;
})
.then(function(hook) {
 var jsonData = JSON.parse(hook);
  var length = jsonData.length;
  var output = =];
   for (let i = 0; i < jsonData.records.length; i++){   // This for loop processes each record and sends to the SMS webhook
    let body = {
      mobile: jsonData.recordsti].fields.Mobile,
      name:  jsonData.recordsii].fields.Name
    };
    Â
    console.log(body);
    Â
//the following fetch part works when I’m testing the zap part (on Zapier) but not when it runs automatically when the scheduler calls it.
    fetch('https://hooks.zapier.com/...', {
      method: 'post',
      body:   JSON.stringify(body),
      headers: { 'Content-Type': 'application/json' }
    })
    .then(res => res.json())
    .then(json => console.log(json));
    Â
    output.push(jsonData.recordssi].fields);
   }
 callback(null, output);
})
.catch(callback);