javascript - TypeError: table.select(...).then 不是函数?
问题描述
exports.checkWhitelist = (emailToCheck) => {
//calls Airtable using req email
table.select({
filterByFormula: {email}=emailToCheck
}).then(res => {
if (!Array.isArray(res.records) || !res.records.length) {
res.send({
"Success":false,
"responseCode":403
})
return True
}
}
)
};
此函数根据 Airtable 中的白名单检查传入的电子邮件。.select 方法调用特定表(白名单)并传入 emailToCheck 作为参数。如果 Airtable 的响应是一个空数组,我知道该电子邮件不在我们的白名单上。否则,该函数应返回 True。
我得到的错误是: TypeError: table.select(...).then is not a function - 我错了什么?
解决方案
我没有使用 Javascript 与数据库进行太多交互,也没有在 Promise 方面经验丰富,但是最有可能发生的事情是它table.select
没有返回 Promise,也许检查值emailToCheck
和对该值的操作,如果它不是解决方案,至少它是一个开始。
推荐阅读
- python - 如何使用 asyncio 和 aiohttp 异步通过 api 响应进行分页
- css - 如何将 Grommet 标题组件中的文本大写?
- php - 使用 CURL 通过 JSON 传递变量
- python - 如何获取 Pytorch 中每一层的前驱节点?
- swift - 如何在pickerview rowHeightForComponent 中获取行号?
- android-studio - 未处理的异常:坏状态:未来已经完成
- android - “ProjectionType”和“UsePanoramaViewer”标签的Android Studio Exif标签编辑
- vb.net - 如何声明没有驱动器号的路径?
- matlab - 如何通过名称判断一个函数是内置的还是自定义的?
- php - 在 PHP 中创建有效的 RSS 提要时遇到问题