This is a tutorial on YouTube, why does asyncFunction() and asyncFunction2 take time to return a promise if there is no connection with a server so there shouldn't be any delay
— While loop Do while Condition use and function and all
— What do you mean by “take time”? It literally takes seconds?
— Look at the pinned message. 👍
— I just finished this playlist and now I know how to use promises 🍾
— That's me
— After this playlist
— I will try to break down the pieces: - asyncFunction is called - console.log is called with “The code is asynchronous” - asyncFunction returns a value and its passed down its then - console.log is called with the value returned of asyncFunction - asyncFunction2 is called - asyncFunction2 returns a value - asyncFunction.then.then will catch the resolution of asyncFunction2 promise - console.log is called with the value returned from asyncFunction2
A few additional points: - A promise.then will always return a promise. - You can return a value or another promise in the .then callback and if it was a promise it will resolve and you can catch the response in the next concatenated then. - asyncFunction2 is not executed until asyncFunction is resolved.