Models
AJAX Abstraction for a Single Resource
AJAX Abstraction for a Single Resource
The fetch()
method is used to retrieve a resource.
You can learn about how this method can be used to retrieve resources here.
fetch: function(options) {
options = _.extend({ parse: true }, options);
// After a successful fetch, the model is updated with the server-side state.
const model = this;
options.success = function(attributes) {
if (options.parse) {
attributes = model.parse(attributes, options);
}
if (attributes && !model.set(attributes, options)) {
return false;
}
};
return this.sync('read', this, options);
},