You need to have an account on the airtable website and set an A.P.I. key on this.
Create a folder named Airtable001 pen in Visual Studio Code.
Create a file named app.js.
On the terminal and start the project with npm init command and select the app.js file when the running init ask it.
Install these packages with NodeJS in this folder.
1 2 | npm install nodemon --global npm install airtable |
After install add this source code in the app.js file:
1 2 3 4 5 6 7 8 9 10 | var Airtable = require('airtable'); var base = new Airtable({apiKey: 'your-key'}).base('your-app-id'); const table = base('Tasks'); const getRecords = async () => { const records = await table.select({maxRecords:3,view:'All tasks'}).firstPage(); console.log(records); } getRecords() |
The last step is to test with this command:
1 2 3 4 5 6 7 8 9 10 11 12 13 | \Airtable001>nodemon app.js [nodemon] 2.0.16 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node app.js` [ Record { _table: Table { _base: [Base], id: null, name: 'Tasks' ... |
You can see the result output from my airtable Tasks project.
You can find this project on my GitHub repo named Airtable001.