There's an Airtable that's been shared with my account (A) from account (B). I have a personal access token from account A.
- The Airtable's restricted to account A's domain
- The Airtable is password protected
Is it possible to use the API to fetch the records of the Airtable?
I've tried this approach:
const Airtable = require("airtable");
const PERSONAL_ACCESS_TOKEN = "...";
const baseId = "...";
const tableName = "...";
const base = new Airtable({ apiKey: PERSONAL_ACCESS_TOKEN }).base(baseId);
base(tableName)
.select({})
.eachPage(
function page(records, fetchNextPage) {
records.forEach(function (record) {
console.log("Retrieved", record);
});
fetchNextPage();
},
function done(err) {
if (err) {
console.error(err);
return;
}
console.log("Finished fetching records");
}
);
```
and this approach:
```
const fetchAirtableData = async (baseId, tableName, personalAccessToken) => {
try {
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${personalAccessToken}`,
"Content-Type": "application/json",
},
});
if (!response.ok) {
console.log(response);
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data.records;
} catch (error) {
console.error("Error fetching data from Airtable:", error);
throw error;
}
};
```
...and neither worked.