Edit on val.town ↗

Store data in Airtable

Airtable is a spreadsheet-database hybrid. Note that because Val Town uses Deno, we use an unofficial library to access Airtable.

On the homepage, click Start from scratch to create a base:

untitled.png

If prompted with automatic setup, click Skip. You should get a new base with a blank table.

untitled-1.png

Adjust the table fields as you want (note that this isn't covered by this guide).

Click on your profile icon, then on Developer hub:

untitled-2.png

Click Create new token.

untitled-3.png

Fill out the fields:

Lastly, click Create token. Here's an example of how your settings could probably look like:

untitled-4.png

Copy your token and click Done.

untitled-5.png

Go to val.town, click on your username and then on Env Variables:

env-variables-menu.png

Click New env variable. Set the key to a name you want to use to reference the token (for example, airtable_pat) and paste the copied personal access token into the value, then click Add.

env-variables-new.png

You can then use Airtable from val.town like so:

import { Airtable } from "https://deno.land/x/airtable@v1.1.1/mod.ts";

const airtable = new Airtable({
  apiKey: Deno.env.get("airtable_pat"),
  baseId: "appXSrKDlwbAijRmD",
  tableName: "All content",
});
// Sample data from: https://blog.airtable.com/database-vs-spreadsheet/
const results = await airtable.select();
console.log(results);

Make sure to change:

untitled-8.png

Last updated