【问题标题】:Strapi toObject() is not a function errorStrapi toObject() 不是函数错误
【发布时间】:2020-08-10 19:39:02
【问题描述】:

我正在尝试按照上的文档在strapi中执行自定义查询 https://strapi.io/documentation/v3.x/concepts/queries.html#custom-queries

但是我一直遇到 toObject 函数未定义的错误

我的方法:

const result = strapi.query('balance').model.find({
          _id: "5f319bd650d74b153c8329dd",
        });
        console.log(result)
        const fields = result.toObject()

错误:

TypeError: result.toObject is not a function

【问题讨论】:

    标签: node.js mongodb strapi


    【解决方案1】:

    在这种情况下,您不需要使用 .toObject(),但您需要将查询设为 async/await。

    【讨论】:

    • 感谢它的工作。我们什么时候应该使用 toObject() 呢?
    • 你能否强调一下我猜等待丢失了,以便其他访问的人更清楚
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-24
    • 1970-01-01
    • 1970-01-01
    • 2017-10-23
    • 2013-01-04
    • 1970-01-01
    • 2017-05-09
    相关资源
    最近更新 更多