Skip to content

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 us…

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…

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 asy…

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 callba…

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…