title: Node.JS - I need to call REST API endpoint in infinite loop in my app
body: <p>I have Node.JS server application which communicates with more clients via Web Sockets. Now I need to extend my solution in this way: Every time when a client connects to the server and obtains a unique ID so from this point it is necessary to constantly call one special REST API endpoint (in some kind of infinite loop) with obtained client ID as a parameter and process changes comming from the REST API's response.</p>
  
  <p>Example:
  - Client 1 connects to the server. Web socket is opened and communication is opened. At this point the infinite loop starts and REST endpoint (e.g. /info?clientId=Client1) is called again and again...</p>
  
  <ul>
  <li><p>after 5 minutes Client 2 also connects to the server and REST endpoint starts to be called again and again (/info/clientId=Client2).</p></li>
  <li><p>suddenly /info?clientId=Client1 returns changed data and now it is a time to react. I will send some special response to opened web socket but infinite loop should still run for both Client 1 and Client 2. </p></li>
  </ul>
  
  <p>This should be same for all clients (also new connected clients at a time when some other clients are being served).</p>
  
  <p>I do not know how should I implement this loop... I tried to google it but maybe if you could give me some advice or recommend me some articles it would be very helpful for me...</p>