Message from JavaScript discussions

May 2019

— What dont you understand about async await?

— 

If I'm working just on front end is there any situation that I can use asynchronous function? Or is it just with a server?

— Sure e.g when you fetch something

— So I ment offline mode, is there a use for it when you want to wait for a reaction after event listener for example

Message permanent page

— Or is it just for online stuff

— You can do fetch('text.txt')
.then(res=>res.txt())
.then(data=>data)
.catch(err=>err)

— You use to wait for a promise to be resolved. In node you can use it nicely for file system operations in the browser to fetch any stuff online. You coulf also use it together with setTimeout() to write blocking code with it.

Message permanent page

— Its just about promises

— So when the event listener fires how do I prepare a file for later fetching?

— I didn't get to node.js yet

— Edited

— Async await is just a clean way to work with promises. Not having to chain .then().then()