Apr 05, 2021 12:11 AM
please help me with this.
Any type of help is highly appreciated.
require(“dotenv”).config();
const Airtable = require(“airtable”);
const base = new Airtable({ apiKey: process.env.API_KEY }).base(
" "
);
const express = require(“express”);
const cors = require(“cors”);
const bodyParser = require(“body-parser”);
const app2 = express();
app2.use(cors());
app2.get("/featuredPaths", (req, res) => {
console.log(“query params::”, req.query);
var remOrLoc = req.query.remOrLoc;
var skill = req.query.skill;
var site = req.query.site;
var skillnew = req.query.skillnew;
var country = req.query.country;
var vetted = req.query.vetted;
var limit = JSON.parse(req.query.limit || 100);
// var formula = “FIND(’” + sitename + “’,Sitename) > 0”;
var formula =
“SUM(FIND(’” +
remOrLoc +
“’, Remote_or_Local) > 0, FIND(’” +
skill +
“’,Skills) > 0,FIND(’” +
skillnew +
“’, skills_new) > 0,FIND(’” +
site +
“’, Sitename) > 0,FIND(’” +
country +
“’, Country) > 0,FIND(’” +
vetted +
“’, Vetted) z> 0)”;
var recordSet = ;
var base = new Airtable({ apiKey: " " }).base(
" "
);
base(" ")
.select({
maxRecords: 300,
view: “Grid view”,
filterByFormula: formula,
})
.firstPage(function (err, records) {
if (err) {
console.error(err);
return;
}
records.forEach(function (record) {
console.log("result===============>", result)
var result;
//console.log("Retrieved", record.get("Id"));
//console.log(record.fields);
// var result = {
// title: record.fields.title,
// courseUrl: record.fields.courseUrl,
// };
recordSet.push(record.fields);
console.log(recordSet);
// recordSet.push(result);
});
res.json(recordSet);
});
});
app2.listen(process.env.PORT, () => {
console.log(“Airtable app listening on port port!”, process.env.PORT);
});
Apr 05, 2021 06:10 AM
Hi @Shivam_Solanki, and welcome to the community!
There are a number of articles here that deal with exactly this issue such as this one, and this one.
Jun 03, 2023 01:41 AM
const url = `https://api.airtable.com/v0/BaseId/Tablename?api_key=xxxxxxxx`;
const getData = async () => {
const api = await fetch(url);
let allRecords = [];
const data = await api.json();
allRecords.push(data.records);
let offset = data.offset;
if (offset !== undefined) {
do {
const api1 = await fetch(url + "&offset=" + offset);
const response = await api1.json();
allRecords.push(response.records);
offset = response.offset;
} while (offset !== undefined);
}
allRecords = allRecords.flat();
console.log(allRecords);
};
it might help...