JavaScript Async Await
Why Stack Overflow recommends it
Stack Overflow users link it when answering questions about promises versus async/await and when asking people to refresh how asynchronous JavaScript works.
Recommended by 3 people across 3 different months, 2021 to 2021.
What it is
A short tutorial by Web Dev Simplified explaining what JavaScript async/await is and how to rewrite promise-based code with it so asynchronous code reads like synchronous code. It builds on promises and shows how async/await reduces nesting and improves readability.
What people said
Recommends Harshit · 2021-05 · Stack Overflow · on “Difference between Promise and async/await”
Whenever you create new Promise you get to parameters resolve & reject . Whenever its success case you resolve on failure you reject. In case of resolve it will go to then & in case of reject it will go to catch . Promise is more over like real world promise (it could either be completed [ resolved ] or broken [ reject ]). Though async & await helps you do asynchronous operations in JS. Whenever in async function it encounters await it will wait for that code to be executes and then will move to next line. Refer to this video [this video] for better understanding along with example.
Recommends samthecodingman · 2021-06 · Stack Overflow · on “Firebase function is not realtime(?)”
Your code also has 7 different lines that have an unhandled `Promise` (results/errors aren't handled) and many of these are in loops meaning you could have hundreds of these. Have a look at this article [LINK] , this video [LINK] and this video [this video] to refresh yourself on how they work and how to handle parallel promises properly.
Recommends shamgar · 2021-07 · Stack Overflow · on “Async & await function on Javascript”
In addition for Amar's answer, I'd like to add a little bit Firstly you need to understand asynchronicity. Imagine that I talk to my friend and this is the conversation: me: Hey, can you send me the number of the girl from the party last night? friend: Sure, I will get home and send it to you And before he sends me the number, I try to call her. Doesn't make sense right? So the same logic applies here. The async and await keywords means that there is somthing that should happen before the next line of code getting executed. So if you really want to understand the concept of this asynchronicity, you should learn about higher-order function [LINK] , callback functions [LINK] , promises [LINK]