As described in the previous section, client-server interaction is all about asynchronicity. As we alter our Personal Trainer app to load data from the server, this pattern becomes self-evident.
In the previous chapter, the initial set of workouts and exercises was hardcoded in the WorkoutService
implementation. Let's see how to load this data from the server first.
Earlier in this chapter, we seeded our database with a data form, the seed.js
file. We now need to render this data in our views. The MongoLab Data API is going to help us here.
Note
The MongoLab Data API uses an API key to authenticate access requests. Every request made to the MongoLab endpoints needs to have a query string parameter, apikey=<key>
, where key
is the API key that we provisioned earlier in the chapter. Remember that the key is always provided to a user and associated with their account. Avoid sharing your API keys with others.
The API follows...