Questions tagged [node-async]

Async is a utility module for node.js (although it can also be used in the browser) that provides powerful functions for working with asynchronous JavaScript

Async provides around 20 functions that include the usual 'functional' suspects (map, reduce, filter, each...) as well as some common patterns for asynchronous control flow (parallel, series, waterfall...).

All these functions assume you follow the convention of providing a single callback as the last argument of your async function.


Documentation :

185 questions
2
votes
1 answer

Javascript Async.js Parallel not working with socket.io

I have the following block of code: async.parallel([ function(cb){ module.rpc("user.data",{"username":data.username},cb); }, function(cb){ module.rpc("group.list",{"username":data.username},cb); }, function(cb){…
Kaustubh Karkare
  • 1,083
  • 9
  • 25
1
vote
2 answers

Error of callback is not a function at Timeout._onTimeout

CODE: Named functions to recuse: console.log('before'); getUser(1, getRepositories); // console.log('User',user); function getRepositories(user) { // console.log(user); getRepositories(user.gitHubUsername, getCommits); } function…
Jaini Shah
  • 13
  • 5
1
vote
1 answer

How to grab value from promise in Nodejs

Hi I am writing a nodejs code in Azure functions to capture the username saved in Azure key vault. Here is the code I have written module.exports = async function (context, req) { var msRestAzure = require('ms-rest-azure'); var KeyVault =…
1
vote
1 answer

How nested loop can be decreased in node js callback function?

Please take a look at the sample code first. TestFunc1(user, result, date, function (response) { let x = response; TestFunc2(x, function (response) { let y = response;  TestFunc3(y, function (response) { let z…
Suman Kumar Dash
  • 681
  • 5
  • 19
1
vote
1 answer

node async library filterLimit always returns undefined

I'm trying to async filter a list of file paths to return only existing files. I'm using the async library's filterLimit along with fs-extra. Function below: const asyncFilter = require('async').filterLimit; const fsExtra =…
bazaars
  • 438
  • 1
  • 4
  • 9
1
vote
4 answers

nodejs- Best method to perform multiple async calls inside a function?

I'm creating an API using Express JS (Express 4) framework. I'm pretty new to NodeJS so I would like to know the best way to perform multiple async calls inside the same function. For this example, I've got a function called Login in my Login…
Smokey
  • 1,857
  • 6
  • 33
  • 63
1
vote
1 answer

is it possible to register eventloop in node addon?

AtExit hook is a function that is invoked after the Node.js event loop has ended but before the JavaScript VM is terminated and Node.js shuts down. AtExit hooks are registered using the node::AtExit API. Similarly is there any way to register…
learn
  • 51
  • 1
  • 4
1
vote
1 answer

mongodb query inside node js eachOf loop

I want to add have nested DB query inside a eachOf loop which should be synchronous. Tried so many combinations and which but nothing works for inside of foreach loop. async.eachOf(nc.virtual_devices, function (vd) { ///////// This code…
Inder R Singh
  • 652
  • 1
  • 6
  • 21
1
vote
1 answer

async.each doesn't run callback function

I'm trying to do something after push data from reddit api to array, but callback function doesn't work at all. As you see the code, It's supposed to print Callback function works! but It doesn't. Is there any ideas about this? let optForReddit = { …
boombamboo
  • 459
  • 2
  • 5
  • 14
1
vote
1 answer

How do I make function to running on background?

I have this code periodically calls the load function which does very load work taking 10sec. Problem is when load function is being executed, it's blocking the main flow. If I send a simple GET request (like a health check) while load is being…
1
vote
2 answers

Run multiple MySQL queries in this node.js function

I have this node.js function which returns a Promise after executing a single MySQL query. function deletePoint(PointObj, door_id) { return new Promise(function(resolve, reject) { try { var connection = jonMySQL.getMySQL_connection(); …
guagay_wk
  • 26,337
  • 54
  • 186
  • 295
1
vote
2 answers

Node Error: Route.get() requires callback functions but got a [object Undefined]

I have not found a question with a similar setup... how do I fix this? I'm using node, express routing, request to call a token from an api, and async series to keep everything clean. I simplified the code by only showing one function in the async…
JasonA
  • 241
  • 2
  • 5
  • 13
1
vote
0 answers

Callback already called -> Async waterfall javascript code

I have the code below. I get "callback was already called error on the line after "addToMongo.push(...)". For me that doesn't make a lot of sense since it should only be executed once. Main Code: async.waterfall([ (callback) => { …
trichter87
  • 21
  • 5
1
vote
1 answer

Node Async forEach - How to iterate by keys instead of values

I currently have the following example object: "fruit" : [ { "bananas" : 2, "tomatoes" : 3 } ]; Let's say I'm iterating through it with the following code: console.log(fruit); async.forEach(fruit, function(item, callback) { console.log(item); …
Neekoy
  • 2,325
  • 5
  • 29
  • 48
1
vote
1 answer

How to properly create thousands of cypher nodes over the neo4j REST API?

I need to create a lot (say 50.000) of nodes via node.js in cypher < 3.0.0. I am using a async.times to post all cypher queries. However it seems that the REST API is chocking (and dies) because there are probably too many requests coming through. I…
Sonu Kapoor
  • 1,567
  • 3
  • 16
  • 34