How do I reference data from Airtable via the REST API?

I’ve connected my site to my Airtable base for a simple blog setup, but I’m not sure how I can pull this data into the Builder. Any explanation would be great

Assuming you have successfully linked Divhunt with Airtable using your API key, follow these steps to seamlessly connect your Airtable table with Divhunt:

Step 1: Select a tag that you want to use for a method

In example below, Method is being called on a tag ‘Blog Post’.

image

Step 2: Select a method on a selected tag

In the right sidebar, go to Advanced tab > Method > Source > Folder Airtable and select table from Airtable that you want to use.

Step 3: Connect data from Airtable to your tags

Now, each tag within a tag that has a Method attached to it can access data from Airtable. This data is stored in the ‘value’ variable. In Divhunt, this functionality operates similarly to how objects work in JavaScript.

Heres an example:
To retrieve a title from Airtable, simply insert the following code into the content of your title element. This assumes that the field name for the title within Airtable is ‘Name’:

${value->get('fields')->get('Name')}

You can easily see all fields that you have access to with simple command ‘encode’.

${value->encode} // This will return full object coming from Airtable

The following example demonstrates how you can access nested data within an Airtable object.

${value->get('fields')->get('Cover Image')->index('0')->get('url')}

Functions such as index(‘0’) are default functions of Divhunt, you can learn more about them here.
Additionally, you can create custom JavaScript functions in the File Manager to modify your content before displaying it to users.

1 Like