【问题标题】:Parse Cloud Code getting Error Failed with: TypeError: Object 0 has no method 'set'解析云代码获取错误失败:TypeError:对象 0 没有方法“设置”
【发布时间】:2015-03-30 16:40:27
【问题描述】:

我正在为我的 Android 应用程序使用 Cloud Code。 将值保存到 Parse 类后,我想更新用户的字段(学分)。

var query = new Parse.Query(Parse.User);
query.equalTo("householdOf", request.params.household);  
query.find({
success: function(roomMates) {
for (var roomMate in roomMates)
{
 if(roomMate != currentUser)
 {
   roomMate.set(
    {
      credit: 3   
    }, 
    {
        error: function(gameTurnAgain, error) 
        {
            console.log("set failed " +error.code + error.message);
            response.error("error");
        }
    });
 }
}

这是我的云代码。我得到了 roomMate.set 的错误 (TypeError: Object 0 has no method 'set') roomMates 必须是 Parse.User 还是我错了?

【问题讨论】:

    标签: parse-platform parse-cloud-code


    【解决方案1】:

    我不是 JS 专业人士,但我也在玩 parse Cloude Code。所以我想你错误地列举了 roomMates。

    您应该枚举数组并获取如下对象:

    for (var i=0; i<roomMates.length; i++) {
     roomMate = roomMates[i];
    }
    

    key in 枚举器在键值字典中用于枚举键。

    var dictionary = {key1 : "Hi", key2: "Bye"};
    for (var key in dictionary) {
     obj = dictionary[key];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-15
      • 1970-01-01
      相关资源
      最近更新 更多