Created
May 27, 2020 23:56
-
-
Save timschafli/c6ac3b71041d35fb813dc6f887789aca to your computer and use it in GitHub Desktop.
Get Records in Airtable and Fork Zap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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