Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timschafli/c6ac3b71041d35fb813dc6f887789aca to your computer and use it in GitHub Desktop.
Save timschafli/c6ac3b71041d35fb813dc6f887789aca to your computer and use it in GitHub Desktop.
Get Records in Airtable and Fork Zap
let authHeaders = {
'Authorization': `Bearer ${inputData.apiKey}`,
'Content-Type': 'application/json'
};
let options = {
method: 'GET',
headers: authHeaders
};
let url = `https://api.airtable.com/v0/${inputData.base}/${inputData.table}?maxRecords=${inputData.maxRecords}&view=${inputData.view}`;
fetch(url, options)
.then(function(res) {
return res.json();
})
.then(function(res) {
// add row numbering
for (let i=0; i<res.records.length; i++) {
res.records[i].currentRowNumber = i+1;
}
return res.records;
})
.then(function (json) {
callback(null, json)
})
.catch(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment