O'Reilly logo

Node.js the Right Way by Jim R. Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 our bundle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required