Created
July 9, 2016 22:00
-
-
Save TooTallNate/bc70a5397883b2f76cbc3ae7708f7b54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These theoretical API requests are deferred promises; | |
// Not executed until `.then()` is invoked. | |
let a = new Request('/foo'); | |
let b = new Request('/bar'); | |
let c = new Request('/baz'); | |
// If invoked directly, then issue 3 direct HTTP requests: | |
Promise.all([ a, b, b ]).then((results) => { | |
// GET /foo | |
// GET /bar | |
// GET /baz | |
}); | |
// OR if you want to batch these API requests, then you could use | |
// the theoretical batch API endpoint and pass the requests in: | |
let batch = new BatchRequest([ a, b, c ]); | |
batch.then((results) => { | |
// GET /batch?%2Ffoo,%2Fbar,%2Fbaz | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment