Whenever we Write async in function, that particular function will return a promise.
And when we write `await` in Function it means, it (await) saying to request that, I am doing my work here and it will take some time, till then you can go back and complete your other task in the file/outside that function typically,
So once the request completes all the tasks outside the function then the request will again go back to the last `await` operator and again ask that `await operator` if he completed his task or not. if he still not completed that task then `Await operator` says no please complete your all task then the request says that I completed my all the task. so await says please wait I will complete my task so you can proceed further.
so once the await completes him all task then the request will be passed further.
if there is any other `await operator` in the function then again request asks to await operator if req can go further if he can then the next code will be executed or req. will wait for `Await operator to complete his task. once done then req can go ahead and complete the next task.
REF: https://www.youtube.com/watch?v=AyJq1RRaY_k
0 comments:
Post a Comment