Strapi.io Controller.find().exec(...)

Strapi.io Controller.find().exec(...)

本文关键字:exec find io Controller Strapi      更新时间:2023-09-26

我尝试使用controller.find().exc(…)方法,并在exec回调函数下尝试创建正文内容。但我不知道该怎么办。我想我必须在那里使用yield关键字,但如果我试图在回调函数中使用yield,它会导致一个错误。我的代码看起来像这样:

let value;
Firstcontroller.find().exec(function (error, result) {
    value = yield result;
});
this.body = value;

我已经尝试过让步和不让步,让和不让步。还有一些选择。如果你有任何想法,请让我分享。我必须使用exec,因为我必须使用结果并将其传递给另一个find方法。

请尝试以下操作:

// Retrieve the value
const value = yield Firstcontroller.find();
// Set the value to the body
this.body = value;