Retrieving Data from the Server

Your RemoteDataStore module can save individual coffee orders to the server. The next thing to do is add a getAll prototype method so that it can retrieve all orders from the server. Get it started in remotedatastore.js:

...
  RemoteDataStore.prototype.add = function (key, val) {
    ...
  };

  RemoteDataStore.prototype.getAll = function () {
    // Code will go here
  };

  App.RemoteDataStore = RemoteDataStore;
  window.App = App;
...

Next you will add a call to jQuery’s $.get method. Like $.post, you will pass it the server URL. But you will not pass it any data, because you are retrieving information instead of saving information. You will need to pass it a function argument so that it knows what to do with the data ...

Get Front-End Web Development: The Big Nerd Ranch Guide 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.