Run function while async function is pending

I want to learn how can I run a function while part of my code is still running, like an async function or some loop that can take some time to finish. For example, while fetching data from an API, I want it to display a loading animation or message while the async function is pending
4 Replies
Pi, a future fluent jp speaker
I thought in something like this but this is not a proper way, I am sure. I want that message to display after the user inputs the "word", and make it disappear when the "fetch' function and the new DOM elements are done
No description
Jochem
Jochem11mo ago
that is 100% the way that is done. You set the loading thing up, then do the fetch, and in the .then, you unset it
Pi, a future fluent jp speaker
Really? That makes things easier then
Jochem
Jochem11mo ago
yup
Want results from more Discord servers?
Add your server