首页 > 解决方案 > 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 - 我错了什么?

标签: javascriptnode.js

解决方案


我没有使用 Javascript 与数据库进行太多交互,也没有在 Promise 方面经验丰富,但是最有可能发生的事情是它table.select没有返回 Promise,也许检查值emailToCheck和对该值的操作,如果它不是解决方案,至少它是一个开始。


推荐阅读