Relative Content

Tag Archive for javascriptasynchronous

Why can async code only be called by async code?

Could someone explain why async code needs to be called by async code in a few more words than this? I understand that async-await is just promises under the hood, so it makes sense that any code after an await is equivalent to a callback in then(). I also have an intuition for why internally the code after an await would need to close over anything before it, if it’s broken up into a separate callback. I don’t understand why it’s closures all the way back to main though?

How do I get the data from an xhttp download to a string variable in Javascript and use it in my app

Here’s what I’m trying to do: NOAA offers data from public datasets on all kinds of climate data. What I am trying to do, in a javascript-only solution, is download the station and station metadata files from NOAA (plain text positional files), parse the metadata file for weather stations with the data I want (precipitation, daily max temps, min temps, and mean temps. From those data I can download the weather data from a station, and plot it using Plotly.