title: Node.js: Continuous execution from settimeout when expecting node to do nothing until settimeout interval over
body: <p>I'm writing a notifier for 3 deal of the day websites in node. I go and parse the body of the webpage to grab the details. In the details there is a timer for the how long the deal will last. I'm reading that timer and trying to use setTimeout/setInterval to set when the function should execute again. However the function calls are continuous instead of waiting.</p>
  
  <p>Pseudo code of what I'm doing:</p>
  
  <pre><code>var getData = function(url) {
  request(url, function(err, resp, body){                                                                                      
         if(err)   throw err; 
  //process the body getting the deal information and timer
  setTimeout(getData(url),timer*1000);
  }
  
  getData(url1);
  getData(url2);
  getData(url3);
  </code></pre>
  
  <p>Full code <a href="https://github.com/nickklosterman/BashScripts/tree/master/DealScrapers/BackcountryWebsites/node/pageScraper" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I want the program to run, continually calling itself with the new timeouts for the webpages.</p>
  
  <p>I'm a Node.js newbie so I'm guessing I'm getting tripped up with the async nature of things. </p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>EDIT:
  more simply : </p>
  
  <pre><code>var hello = function(){
  console.log("hello");
  setTimeout(hello(),25000);
  }
  
  hello();
  </code></pre>
  
  <p>prints out hello continuously instead of hello every 2.5s. What am I doing wrong?</p>