0

Let's say I have two async functions.

const functionTwo = async () => {
    //do something
}

const functionOne = async () => {
    try { 
        //do something
        functionTwo();
        //do something else
    } catch (e) {
        handleError(e)
    }
}

I dont want functionOne() to wait for functionTwo() to finish its execution so I didn't put await infront of functionTwo(). I'm using WebStorm IDE and its showing a warning that I should either put await or add .then() to functionTwo() call. Is it the right thing to do to put .then(), even when i don't need to do anything in it?

S V
  • 68
  • 6
  • 3
    Feel free to ignore it if you really don't need it, and if errors will be properly caught. *Usually* it's a mistake, which is why there's a warning - but there are exceptions. – CertainPerformance Mar 24 '22 at 05:47
  • You're right, no need to put an `await` or a `.then()`. Moreover, if you're not doing any async work in `functionOne` or you don't need to wait for it to get done, you can even remove the `async` keyword for `functionOne` – Shreshth Mar 24 '22 at 05:50
  • @Shreshth functionTwo() itself has some async function calls, so it definitely needs to be ```async``` – S V Mar 24 '22 at 05:58
  • 2
    https://stackoverflow.com/questions/32384449/can-i-fire-and-forget-a-promise-in-nodejs – Bergi Mar 24 '22 at 06:28

0 Answers0