Answer the question
In order to leave comments, you need to log in
JS, what's under the hood of the async await construct?
Hello, what happens when we call await function fetchUser().
I believe that this is a wrapper over a generator that suspends the course of an asynchronous function.
But I've also seen that it's just a call to Promise.all([]). So what's going on under the hood?
Answer the question
In order to leave comments, you need to log in
Yes, under the hood there are generators and promises. One way to test this is to transpile your async/await code to ES5 using Babel and see what happens. I made a small gist with a test project, you can see the result there. Babel uses regenerator to implement generators.
Detailed answer to the question in English.
async / await is syntactic sugar. Under the hood is a generator and yield .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question