Does anyone have an example of a piece of code where a Future that returns a Future? Can be JS too: a Promise that returns a Promise. I'm curious when this might be used, rather than just having it be a theoretical example.
-
-
Replying to @yoshuawuyts
I think fetch in the browser does this: fetch(jsonUrl) .then(function(res) { return res.json() }) .then(function(myJson) { console.log(JSON.stringify(myJson)) }) Or it can be written with async/await: JSON.stringify( await (await fetch(jsonUrl)).json() )
2 replies 0 retweets 1 like
Replying to @jake_brdn
With newlines: var req = await fetch(jsonUrl) var json = await req.json() JSON.stringify(json) I guess similar situations would occur with fs operations. I guess it's different than what I imagined, tho it seems similar?
6:24 AM - 20 Jan 2019
0 replies
0 retweets
1 like
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.