From the course: JavaScript: Async
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Appending methods to resolved promises - JavaScript Tutorial
From the course: JavaScript: Async
Appending methods to resolved promises
- So far, our code returns an object from a promise, and that means we're on the right track, but we want to do something with that object. The object returned by a resolve method isn't meant for direct examination. It itself is a promise and requires specific syntax to work with. To handle the object return from a successful promise, we simply append the then method to the promise call. Then expects a promise as an argument and enables you to work with the result data embedded in that object. And you can chain as many then methods as you want. One after another, allowing you to work with data synchronously or asynchronously and hand off the result to another function at each step. And this makes code easier to read, than nested callback sometimes do. In our get function for the Explore California site. We want to dig into the data returned from our HTTP request. So to do that, instead of logging that object to the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Understanding promises2m 46s
-
(Locked)
Building asynchronous code with promises3m 59s
-
(Locked)
Appending methods to resolved promises2m 38s
-
(Locked)
Using catch methods for rejected promises3m 52s
-
(Locked)
Using the finally method for executing handlers3m 32s
-
(Locked)
Preparing the all method for executing multiple promises2m 16s
-
(Locked)
Implementing the all method for executing multiple promises6m 39s
-
(Locked)
Making code backward-compatible with polyfill1m 29s
-
(Locked)
-
-
-