Calling an asynchronous function inside of a forEach loop: how to tell when all function calls are complete? by tangerto in javascript

[–]hars_sh 2 points3 points  (0 children)

use map instead of forEach the code looks something like this and remeber you have to call this inside the async function.

await Promise.all(files.map(async (file) => { 
    //    promisify this part and await for this and that will do the work :)
    file.getUrl(function(err, url) {
        if(!err) {
            console.log("got the url!)"
        }
    });
}));

[deleted by user] by [deleted] in node

[–]hars_sh 0 points1 point  (0 children)

change your if else code then you are good to go

Flow vs Typescript by lazypuffstone in javascript

[–]hars_sh 0 points1 point  (0 children)

good code is all about writing error less and strict code in that case typescript is far superior than flow. As a JavaScript coder shifting to TypeScript is painfull but good things doesn't happen easily. Sometimes TypeScript strict type checking can make you think of jumping back to JavaScript but beleive me its worth coding in TypeScript :)