jashkenas / backbone

Give your JS App some Backbone with Models, Views, Collections, and Events
http://backbonejs.org
MIT License
28.09k stars 5.39k forks source link

Model.fetch() not working after overriding sync method #4229

Closed sohankd closed 4 years ago

sohankd commented 4 years ago

To add some extra options to header i override the sync method. when i try to fetch the data it simply shows the empty model in console. Even there is now sign of making request to server found in network tab. While Backbone.ajax() works fine. Can you tell me what could be the missing point. var model = new MovieModel(); model.fetch(); /// empty model in console ` define('Backbone.Model' , [ 'Configuration' , 'backbone' , 'underscore' ] , function ( Configuration , Backbone , _ ) { 'use strict';

return _.extend(Backbone.Model.prototype,{

    sync: function(method,model,options)
    {
        if(model && model.includeToken)
        {
            options.headers = _.extend(options.headers || {}, {
                'Authorization': `Bearer ${Configuration.tmdb['auth_key']}`
            });
        }
    }
});

}); `