【问题标题】:Meteor bindEnvironment: "Did not check() all arguments"Meteor bindEnvironment:“没有检查()所有参数”
【发布时间】:2015-01-03 02:41:39
【问题描述】:

我下面的代码在服务器上抛出一个错误:

调用方法“/app/shipping/ship”时出现异常错误:在调用“/app/shipping/ship”期间未检查()所有参数

Meteor.methods({
  '/app/shipping/ship': function (weight, length, width, height) {
    check(weight, Number);
    check(length, Number);
    check(width, Number);
    check(height, Number);

    var async = Meteor.npmRequire('async');

    var quote = function (callback) {
      Meteor.call('/app/shipping/quote', 'DE', weight, length, width, height, function (err, res) {
        if (err) {
          callback(err);
        }
        else {
          callback(null, res);
        }
      });
    };

    async.waterfall([
      Meteor.bindEnvironment(quote)
    ], function(err, result) {
      console.log(result);
    });
  }
});

我认为我已经检查了所有参数(重量、长度、宽度和高度),我还需要检查其他地方吗?

谢谢!

【问题讨论】:

    标签: node.js asynchronous meteor callback npm


    【解决方案1】:

    audit-argument-checks 通过检查传递 到方法的所有参数而不是定义 参数来工作。您的问题最可能的原因是您在代码中的某处使用大于四个参数调用该方法,例如:

    Meteor.call('/app/shipping/ship', 1, 2, 3, 4, 5);
    

    【讨论】:

    • 有趣,我会研究一下。现在,在 Meteor.call() 回调中再次检查解决了这个问题。
    猜你喜欢
    • 2018-07-01
    • 1970-01-01
    • 2013-11-28
    • 2021-04-19
    • 2014-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-23
    相关资源
    最近更新 更多