RESTful APIs with Promises

One thing I really love about JavaScript is its extreme flexibility. In JavaScript there are seven different ways of doing anything, and you get to pick the one you like. This is especially true of managing asynchronous code.

We’ve already seen a number of approaches to working with asynchronous code in JavaScript. Early on, we used regular Node.js callbacks, and then talked about EventEmitters and streams. We explored the async module and its suite of asynchronous coding utilities, as well.

Now let’s turn to the RESTful APIs for editing book bundles. Here we’ll talk about promises—another approach to managing asynchronous code.

Creating a Resource through POST with a Promise

The first thing we’ll need for ...

Get Node.js the Right Way 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.