Let’s return to our Express APIs for working with book bundles. So far we have ways of creating and retrieving bundles, and we can update the name property of a bundle.
Now we’ll make an API for adding books to a bundle using the PUT HTTP verb. This code will have to make several asynchronous calls: one to get the existing bundle, one to get book details, and one to put the bundle data back. To do all this, we’ll use promises and generators to flatten and simplify the chain of operations.
Before we get into the code, let’s take a look at how this API works. That way, when we dive into the code it’ll be more clear what it’s doing.
To use the PUT book API, we need a bundle, so make one with the ...