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.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With