JavaScript async/await implemented in V8
chromium.googlesource.com
JavaScript async/await implemented in V8
1–10 of 227 posts
Re: JavaScript async/await implemented in V8
#2Re: JavaScript async/await implemented in V8
#3https://www.twilio.com/blog/2015/10/asyncawait-the-hero-java...
Re: JavaScript async/await implemented in V8
#4Getting data is as easy as:
async function main () {
try {
const res = await fetch('https://api.github.com/orgs/facebook');
const json = await res.json();
console.log(json);
} catch (e) {
// handle error
}
}
So I am quite happy when this lands in modern browsers asap.Re: JavaScript async/await implemented in V8
#5async/await is the final piece in the puzzle of providing real solutions to callback hell in JavaScript.
Re: JavaScript async/await implemented in V8
#6Well, it claims to be a prototype. Can anyone from the team comment?
Quite exciting in any case!
Re: JavaScript async/await implemented in V8
#7The moment I started using async await (with babel) combined with the new fetch API so many libraries got obsolete. Getting data is as easy as: async function main () { try { const res = await fetch('https://api.github.com/orgs/facebook'); const json = await res.json(); console.log(json); } catch (e) { // handle error } } So I am quite happy when this lands in modern browsers asap.
const json = await (await fetch(https://api.github.com/orgs/facebook')).json();
or do I have to name it?Re: JavaScript async/await implemented in V8
#8The moment I started using async await (with babel) combined with the new fetch API so many libraries got obsolete. Getting data is as easy as: async function main () { try { const res = await fetch('https://api.github.com/orgs/facebook'); const json = await res.json(); console.log(json); } catch (e) { // handle error } } So I am quite happy when this lands in modern browsers asap.
Is the syntax composable? Can I do const json = await (await fetch(https://api.github.com/orgs/facebook')).json(); or do I have to name it?
Re: JavaScript async/await implemented in V8
#9Re: JavaScript async/await implemented in V8
#10The moment I started using async await (with babel) combined with the new fetch API so many libraries got obsolete. Getting data is as easy as: async function main () { try { const res = await fetch('https://api.github.com/orgs/facebook'); const json = await res.json(); console.log(json); } catch (e) { // handle error } } So I am quite happy when this lands in modern browsers asap.
Is the syntax composable? Can I do const json = await (await fetch(https://api.github.com/orgs/facebook')).json(); or do I have to name it?
EDIT: I missed the `.json()` part, but I suppose it doesn't return a Promise, no?