Chapter 8. Basic API Concerns
In the last chapter, you used an API that was “canned” to learn about populating a collection with fetch()
. Since Backbone.js is backend agnostic, you could work with any programming language or data store to build a “real” application stack. However, with the advances of Node and JavaScript, some of the concepts that apply to Backbone at the client equally apply when building APIs or connecting to data stores at the server.
Even if your use case does not require an isomorphic application design, where logic for templating and data validation can be shared, the concepts of this chapter should help you understand more enhancements of Backbone models and collections to “write” state to a remote server.
To persist state with Backbone, we delve deeper into concepts from API development. This is why this chapter on general persistence, and the next chapter on authentication, move the development of Munich Cinema more and more toward full stack JavaScript application development.
Our discussion on fetching movies is extended to storing votes on movies. In general, changing application state also requires discussion on authenticating users. But to simplify the discussion in this chapter, we let users vote on movies without authentication. Then, in the next chapter, authentication will be discussed.
To store state from the client at a server, we first replace the mock API with a Movies API based on Restify and JavaScript promises based on Bluebird. We then connect ...
Get Full Stack Web Development with Backbone.js now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.