alekseykulikov/backbone-offline

error on fetch/pull

reubano opened this issue · 3 comments

When I run @collection.storage.sync.pull() or @collection.fetch() I get the error TypeError: item.id is undefined. Push works fine and posts to my restapi. Any idea what I'm doing wrong?

Well, the error was with createItem. And the following fixes it

      Sync.prototype.createItem = function(item) {
        // console.log(item)
        if (item.id && !_.include(this.storage.destroyIds.values, item.id.toString())) {
          item.sid = item.id;
          delete item.id;
          return this.collection.items.create(item, {
            local: true
          });
        }
      };

The wierd part is that with the logging on, it spells 'success' with each item being one letter. I don't know why that is.

Another data point.... for ajax queries, the textStatus argument is success on successful calls.

Cool - thanks for the fix of the item.id is undefined bug!