检查Meteor.call上的参数(...)

时间:2014-12-19 11:59:13

标签: meteor

#Meteor v.1.0#Meteor.call(标题,描述)抛出异常

检查客户端上的参数:

'click div[name="saveCollection"]' : function(e) {
    var title = 'Title'
    var description = 'Description'

    check(title, String) 
    check(description, String)

    Match.test(title, String)        --> It's true    
    Match.test(description, String)  --> It's also true 

    Meteor.call('saveCollection', title, description, function(error, result){
    ...
    })
}

检查服务器上的参数:

saveCollection: function (title, description) {
    check(title, String)
    check(description, String)

    Match.test(title, String)        --> It's true  
    Match.test(description, String)  --> It's also true  

    Collection.insert({
       title: title,
       description: description
   })
}
Exception while invoking method 'saveCollection' Error: Did not check() all arguments during call to 'saveCollection'

我做错了什么?

1 个答案:

答案 0 :(得分:0)

正如评论所说,你不打算打电话

Meteor.call('saveCollection', title, description)

而不是

Meteor.call('saveCollection', description, description)

这可能搞砸了审计参数检查。