Trying to make setInterval and clearInterval work with Node JS

Hi, I am doing my best to make a loop that sends an announce every 3 seconds (for instance).
But I can’t manage to stop the loop when it started.
Could someone tell me how to know when the loop is started and how to stop it ?

Here is a shortened version of my script.

You have to define loopAnnounce outside of your function to access the stored interval. Right now, you store the reference in a local variable and throw it away as soon as the function is done.

1 Like

Thank you for the response, could you please tell me how I could do that ?

I would really appreciate your help !

P.S : I managed to solve the problem

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.