【问题标题】:Calling the default blueprint action inside a customized action?在自定义操作中调用默认蓝图操作?
【发布时间】:2018-08-01 09:09:58
【问题描述】:

我想在自定义操作中调用默认蓝图操作。我该怎么做?

根据here,我尝试使用这个:sails.hooks.blueprints.middleware.update(this.req, this.res); 在我的自定义更新操作中

fn: async function (inputs, exits) {

    try {
        sails.hooks.blueprints.middleware.update(this.req, this.res);
    } catch (err) {
        console.log(err);
    }

    return exits.success();
}

但出现错误:TypeError: sails.hooks.blueprints.middleware.update is not a function

然后我尝试声明:let update = require('sails/lib/hooks/blueprints/actions/update'); 并调用

fn: async function (inputs, exits) {
    update(this.req, this.res);
    return exits.success();
}

但没有成功。

我正在使用 Sails.JS v1.0.2。

【问题讨论】:

    标签: node.js sails.js


    【解决方案1】:

    我认为问题在于无法创建新蓝图,而只能被覆盖。因此,要制作自定义蓝图,它必须采用现有蓝图的名称。

    【讨论】:

      猜你喜欢
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多