为什么我在为带有 parse.com 的数组执行 fetchAll 时出现错误

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

本文关键字:fetchAll 执行 数组 错误 com parse 为什么      更新时间:2023-09-26

我有一个对象查询,它与历史对象有一对多的关系。

我的要求是,当用户询问历史记录时,我需要获取所有历史记录对象,然后显示它们

这是我的代码:

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);
    },
  });
}

现在使用当前代码,我收到此错误:

Uncatch 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'

请注意,这甚至不会调用服务器,而是在javascript代码中死亡。知道这里出了什么问题吗?

代码倒数第二行有一个","。 这是一个语法错误,将导致代码失败。

这是正确的代码 ->

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);
    }
});