How Backbone Decides if it Should Use POST/GET/ Request to the Server? What are the Methods Backbone has Reserved for these Operations?
 

Report
Question
10 views

Please explain why do you think this question should be reported?

Report Cancel

If we instantiate a model with an id, Backbone.js will automatically perform a GET request to the urlRoot + ‘/id’ using fetch() method. (conforming to RESTful conventions)
If the id attribute of the model is null, Backbone.js will send a POST request to the urlRoot of the server using save() method.
If the id attribute of the model is not null, Backbone.js will send a PUT request instead of a POST request using save() method.
If a model has an id we know that it exists on the server, so if we wish to remove it from the server we can call destroy() method. destroy will fire off a DELETE /user/id (conforming to RESTful conventions).

Please follow and like us:

About the Author