Connect Node.js to an Airtable Database

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 5 years ago

Airtable is a personal favorite tool for building out small tools and hosting data. Airtable also makes it pretty easy to load data into your Node.js apps to build your own UIs around the data. This lesson walks you through grabbing the API key, using the airtable API, and selecting and viewing data from the records.

Instructor: [00:00] Go to airtable.com and create or sign into an account. Go to your account and generate an API key. Select and copy this in your clipboard. Then, I'm going to create a file called .env and in all caps name and airtable_api_key. The name is important. Set that equal to the key that you copied.

[00:21] To use the .env file in node, I'm going to install .env. In my package JSON, I'll add some scripts. I'll say that my start script is node and tell it to require with -r.env/config and start up in index JS file, which will create right here.

[00:46] This line is telling .env to bring these defined environment variables into this script. Now, we can add the Airtable API. You can find it by clicking on Airtable API here. I want to use the applicant tracking base. Clicking on that gives us this key or ID to the base.

[01:08] I'm going to copy that. Then, I'll require Airtable, so Airtable is require Airtable, and our base is airtable.base, and paste in that ID. Also note, behind the scenes that Airtable is bringing in this API key, because the .env has assigned it to this environment variable being brought in here.

[01:34] Now if you look at the base when I click open base, we want to get this base of applicants, so we'll say applicants is base and pass in applicants. Then on my applicants, I can select a view of...Right here, you can see all applicants.

[01:51] I'll just type in all applicants. I'll call this all. Now, I can say all first page. Then, pass in a function with an error and the records of the first page. If it errors out, you could handle in with this. We're going to get the records. The first page, we'll have the first one hundred records, we only have three.

[02:13] In these records, I want to get the name. I'm going to say the names or records.map. Get each record and say record get name. Then, I can simply console log out all the names. Hit save there, which will reformat a little bit.

[02:32] Then, clear this out into say yarn start. You'll see Chippy the potato, Queen Elizabeth II, and [inaudible] . We brought in each name of then all applicants view inside of the applicants base, inside of the applicant tracking base.

egghead
egghead
~ just now

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today