Skip to content
Advertisement

Tag: async-await

Why function is executed although await is used?

I have used await keyword in the main function to wait for the completion of async function call to poll() and yet the function call to my_plot is made before the completion of the poll() function. Code output: Expected: Answer Don’t use setTimeout directly from within an async function. Instead, use a Promise-based wrapper. It’s surprising that modern ECMAScript doesn’t

Global memoizing fetch() to prevent multiple of the same request

I have an SPA and for technical reasons I have different elements potentially firing the same fetch() call pretty much at the same time.[1] Rather than going insane trying to prevent multiple unrelated elements to orchestrate loading of elements, I am thinking about creating a gloabalFetch() call where: the init argument is serialised (along with the resource parameter) and used

How to log return value after async/await?

Below have I pasted in PoC code, where I have removed lots of lines, but it shows the problem/question I am facing. createPost() returns a “post number” in the ret variable. I don’t need the “post number for anything else than logging it. With the current implementation, I have to define ret outside of the while loop, and since sequential

Advertisement