Hey @daniel_villegas , welcome!
I don’t believe .eachPage
returns anything. Instead, it just iterates through each page. So you’ll have to store the data somewhere, like this:
const data = [];
base("Characters")
.select({
view: "Main View",
})
.eachPage(
function page(records, fetchNextPage) {
records.forEach(function (record) {
data.push(record.fields)
});
fetchNextPage();
},
function done(err) {
if (err) {
console.error(err);
return;
}
}
);
return data;
Does that difference make sense?
Now, for a personal/side project, connecting directly to Airtable from React is fine. But keep in mind your Airtable API token will be available to anyone who loads your React app (as the API token is stored right there, in your app’s code.) So they’ll be able to do anything to your base. If you’re sharing with strangers or publishing this project to the public web, you’ll want to move calls to Airtable to a back-end. (If you use eg Next.js + React, there’s a way to write API functions in Next that are hosted on the back-end)
Cheers,
Anthony