0

I am trying to get return from Backbone.js Collection fetch using code similar to one below. How do I bypass rest ?

var myData = getCollection();

getCollection(){
   this.collection = fetchCollection.fetch({
     success: function(collection, data) {
       collectionData = fetchCollection.toJSON();
       return collectionData; 
     }
  },this);
}  
Me Unagi
  • 405
  • 1
  • 8
  • 17

1 Answers1

1

fetch calls the underlying sync methods, Backbone.sync. You can either override the sync method of individual the collections or models, or replace Backbone.sync with your own. One such alternative sync implementation for instance is the Backbone localStorage adaptor which stores to localStorage instead of using REST to talk to a server.

Marius Kjeldahl
  • 6,830
  • 3
  • 33
  • 37