From the course: JavaScript: Async
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Building asynchronous code with promises - JavaScript Tutorial
From the course: JavaScript: Async
Building asynchronous code with promises
- Modern JavaScript includes a method called Fetch, that creates an asynchronous HTTP request using a syntax that's based on Promises. However, to get practice building Promises from the ground up, we're going to create our own method using the Promises constructor to create and send an XHR request for the weather information on the explore California site. So we're going to start by basically rewriting the GET Method that we've already created. So our GET Method is just creating an XHR request, sending that and then working with the response, and we just want to turn this into code that is actually creating and then working with a Promise. So the first thing I'm going to do is take out the success and fail Callback parameters because Promises don't actually work with those. We don't use Callbacks with Promises, We do that more Under the Hood. And then the first line of my function, I want to return a new Promise, and this…
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)
-
-
-