Node JS, delayed response :: Get response after some time

0
1127

The following piece of code opens up a response stream with the client and streams it to the client. So, in curl you’ll get “Hello” first and “World” after 2 seconds (since you’ve set an interval of 2000 milliseconds).

      res.write('Hello\n');
      setInterval(function() {
          res.end(' World\n');
      },2000);

Reference :- https://stackoverflow.com/questions/19928779/node-js-delayed-response

LEAVE A REPLY

Please enter your comment!
Please enter your name here