Using async's forEach

38 views
Skip to first unread message

Ammar Karim

unread,
Nov 27, 2015, 6:42:20 PM11/27/15
to nodejs
I am trying to use forEach

async.forEach(TeamList, function (value, key, connectStream) {
      connectStream(value); 
  
    }, function (err) {
      if (err) console.error(err.message);
    })

however, it is telling me that "connectStream" is undefined.

any help?

Ryan Graham

unread,
Nov 27, 2015, 10:01:44 PM11/27/15
to nodejs

I don't see a forEach in the async docs, but based on your usage it looks like you are trying to use forEachOf... Except the 3rd argument of the iterator would be the callback for moving on to the next item and it expects an error or null as its only argument. It also expects to be given an object, not an array. If you are using an array, you'll want async.each, and your iterator would only get 2 arguments: item and callback.

Can you give a little more context about what you are trying to do and which module you are trying to do it with?

~Ryan


--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/c543e99a-d2c9-49fb-b745-c9c5a93768d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

~Ryan

Reply all
Reply to author
Forward
0 new messages