- Worked on my dev.to gridsome plugin. Learnt a good technique to iteratively resolve an array of promises one at a time. Sort of deafeating the purpose of promises in some ways.. but really useful if you need to queue up a bunch of requests to an API without hitting a 423 error like what was happening with the dev.to API.
Some really awful solutions.
But this is the best one i’ve found.
async function printFiles() {
const files = await getFilePaths();
for await (const contents of files.map((file) => fs.readFile(file, "utf8"))) {
console.log(contents);
}
}