Reputation: 936
It's easier just to look at the code:
async function addFiles(dir,tree) {
return (await readDir(dir))
.map(name => {await readDir(dir); return name;}) // error here
}
This code returns an error on line 3, saying there's an unexpected token near readDir
. I don't understand why this won't work.
Upvotes: 4
Views: 3757
Reputation: 936
It turns out, I forgot to declare my arrow function as async.
the revised code is
async function addFiles(dir,tree) {
return (await readDir(dir))
.map(async name => {await readDir(dir); return name;}) // error here
}
Upvotes: 5