简体   繁体   English

为什么在使用parse.com对数组进行fetchAll时出现错误?

[英]Why am I getting an error while doing fetchAll for an array with parse.com?

I have an object Enquiry which has a one to many relation with History objects. 我有一个对象查询,它与历史对象具有一对多的关系。

My requirement is that when user asks for history I need to fetchAll the history objects and then display them 我的要求是,当用户询问历史记录时,我需要获取所有历史记录对象,然后显示它们

Here is my code: 这是我的代码:

function fetchAndShowHistory(object, objectType) {
  var historyObjects = object.get("history");
  Parse.Object.fetchAll(historyObjects, {
    success : function(historyObjects) {
      //code to show history objects
    },
    error : function(error) {
      alert("Could not fetch history, " + error.message);
    },
  });
}

Now with this current code I get this error: 现在,使用此当前代码,我将收到此错误:

Uncaught TypeError: Object function (a,d){if(c.isString(a))return b.Object.create.apply(this,arguments);a=a||{},d&&d.parse&&(a=this.parse(a));var e=b.getValue(this,"defaults");if(e&&(a=c.extend({},e,a)),d&&d.collection&&(this.collection=d.collect......l' 未捕获的TypeError:对象函数(a,d){if(c.isString(a))返回b.Object.create.apply(this,arguments); a = a || {},d && d.parse &&(a = this。 parse(a)); var e = b.getValue(this,“ defaults”); if(e &&(a = c.extend({},e,a)),d && d.collection &&(this.collection = d.collect ......我

Note that this doesn't even make the call to the server but dies in the javascript code. 请注意,这甚至没有调用服务器,而是在javascript代码中死亡。 Any idea what is wrong here? 知道这里有什么问题吗?

There is a ',' on the 2nd-last line of your code. 在代码的倒数第二行上有一个“,”。 This is a syntax error and will cause your code to fail. 这是语法错误,将导致您的代码失败。

This is the correct code -> 这是正确的代码->

function fetchAndShowHistory(object, objectType) {
  var historyObjects = object.get("history");
  Parse.Object.fetchAll(historyObjects, {
    success : function(historyObjects) {
        //code to show history objects
    },
    error : function(error) {
        alert("Could not fetch history, " + error.message);
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM