Skip to content
Advertisement

Tag: asynchronous

Mocha test false assert timeouts

I have some problem with my async mocha tests. The assert method within a promise results in a timeout when the input evaluates to false. (with true values it works fine) This is a simplified version of the problem. We usually do networking instead of this constructed promise. Answer You’d better NOT use async/await syntax on the promise constructor. It’s

Async Loop Not Honoring Async

I have been a bit stuck on an Async function. What I am trying to accomplish – I am creating a batchProcessing function (batchGetSubs) which will loop through a set of files, read a ID, then make an API request, wait for a response (THE ISSUE) and then to write to a new file with the formatted data. The issue

Returning Value From Callback in a Map

My problem is depending on the result of an asynchronous operation during a map. I know similar questions have been asked, but cannot quite figure out how to apply this to my case. I have figured out how to solve my problem using synchronous methods, my code is as follows, I want to try writing this using asynchronous callbacks. I

Asynchronous loading of select list options

I’m retrieving information on Municipality names, ZipCodes, etc. from a public service provider (DAWA) using AJAX. At first I had an issue retriving the data until I made the transfer asyncronous, thus ajaxGetMunicipalitiesFromDAWA is an asyncronous function. I have checked ajaxGetMunicipalitiesFromDAWA and it loads data correctly. The I try to update my selectlist using the data, but it seems the

How do I wait for the function to complete?

json/shortcuts.json file is: I’ve tried async and await as well as passing one of the functions as a callback. Nothing succeeded:( I think function works bad because of asynchrony. I just started learning of JS, so i am beginner and kindly ask for help! Thanks! Answer Because axios already have a callback function, so you only need to call createShortcutsTable(shortcuts

Use promise-returning code without async/await

I’m trying to quickly write a simple tool in NodeJS using pdf-lib. pdf-lib appears to be designed to use promises and async/await, but I don’t want the extra code complexity of async/await for such a simple tool. How can I use functions that return a promise without the extra bother of async/await? Answer Since the library primarily uses Promises, you

Repeatedly await asynchronous post requests

I want to repeatedly do a POST request, as follows: But this won’t work, because I’m somehow not using asynchronous programming correctly. Somehow even after spending hours on async js I don’t know if I still get it. EDIT: this code is on the client-side. Answer To sequentially execute the request, you need to return the promise (return value of

Advertisement