我试图通过尝试在用户表中找到他们的电子邮件来查看用户是否存在,如果它不存在,那么我正在插入用户。
var Airtable = require('airtable');
var base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY }).base(process.env.AIRTABLE_BASE_ID);
app.post('/addUser', (req, res) => {
const { uid, displayName, email, photoURL, provider } = req.query;
base('users').find({filterByFormula: `FIND(email = '${email}')`}, function(err, record) {
if (err) res.status(400).send(err);
console.log('Retrieved', record.id);
base('users').replace([{"fields": { uid, displayName, email, photoURL, provider}}], function(err, records) {
if (err) console.log(err)//res.status(400).send(err);
else console.log(records[0])
res.status(200).send(records[0]._rawJson);
});
});
});
我得到的错误是
] AirtableError {
[api] error: 'NOT_FOUND',
[api] message: 'Could not find what you are looking for',
[api] statusCode: 404
[api] }
API 文档在这里: https: //support.airtable.com/hc/en-us/articles/203255215-Formula-Field-Reference
我也试过
base('users').select({filterByFormula: `FIND(email = '${email}')`}, function(err, record) {....
并得到了错误
Airtable: `select` takes only one parameter, but it was given 2 parameters. Use `eachPage` or `firstPage` to fetch records.