Nick this is a great article, but there are some problems (as others have pointed too) with the way you interpret Async/Await as the next evolution of Promises.
You can call Promises as the next evolution of the callback code, but the Async/Await is not exactly an evolution. It is meant to supplement Promises and not replace it. For example you can use a combination of Promises and Await to get a much more readable code than flooding you code with awaits.
In your example
asyncfunctionfoo(){response[0]=awaitaxios.get(`/users/userId=${users[0]}`);response[1]=awaitaxios.get(`/users/userId=${users[1]}`);response[2]=awaitaxios.get(`/users/userId=${users[2]}`);// do the thing}
Async/Await heavy codes like the one above, encounter a problem of running out of variable names (you have used an array, which is clever but doesn't really improve readability)
This code can be improved by doing something by
asyncfunction(){response=awaitPromise.all([1,2,3].map(i=>axios.get(`/users/userId=${i}`));// do the thing}
In a lot of cases you really want to pipe a bunch of results to multiple async calls, for this again promises work like a charm:
Nick this is a great article, but there are some problems (as others have pointed too) with the way you interpret
Async/Await
as the next evolution of Promises.You can call
Promises
as the next evolution of the callback code, but theAsync/Await
is not exactly an evolution. It is meant to supplement Promises and not replace it. For example you can use a combination of Promises and Await to get a much more readable code than flooding you code withawait
s.In your example
Async/Await heavy codes like the one above, encounter a problem of running out of variable names (you have used an array, which is clever but doesn't really improve readability)
This code can be improved by doing something by
In a lot of cases you really want to pipe a bunch of results to multiple async calls, for this again promises work like a charm: