You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which environment did the issue occur in (Node version/browser version)
OS Version: OS X 10.12.6
Node Version: 8.4.0
Browser Version: N/A
What did you do?
// templateNames is an array of strings
async.map(templateNames, async (templateName, next) => {
let template;
try {
template = await utils.getFile(templateName);
} catch(err) {
next(err);
}
...
// and so on
What did you expect to happen? next is an iteratee function
What was the actual result? next is undefined
I ended up just using the .then().catch() syntax to accomplish my goal but still wanted to share that using an AsyncFunction (NOTE: this is not the async definition but the native AsyncFunction Object) results in the iteratee (next) being of type undefined.
The text was updated successfully, but these errors were encountered:
async functions are treated differently as of 2.3.0 -- they are not passed a callback. Instead, just return a value (or Promise). In fact, in your example, even the try/catch is not necessary because any errors thrown will be caught by Async. This should simplify your code a bit.
// templateNames is an array of stringsasync.map(templateNames,asynctemplateName=>{consttemplate=awaitutils.getFile(templateName);
...
// and so on
What version of async are you using?
2.5.0
Which environment did the issue occur in (Node version/browser version)
OS Version: OS X 10.12.6
Node Version:
8.4.0
Browser Version: N/A
What did you do?
What did you expect to happen?
next
is an iteratee functionWhat was the actual result?
next
isundefined
I ended up just using the
.then().catch()
syntax to accomplish my goal but still wanted to share that using anAsyncFunction
(NOTE: this is not theasync
definition but the nativeAsyncFunction
Object) results in the iteratee (next
) being of typeundefined
.The text was updated successfully, but these errors were encountered: