title: errors when putting a function inside setInterval()
body: <p>I have written this code in nodeJs:</p>
  
  <pre><code>function ricarica() {
  
     request.get(url, function (error, response, body) {
         if (!error &amp;&amp; response.statusCode == 200) {
             var json = JSON.parse(body);
             //console.log(json[11].nome_abbr);
             //console.log(json[11].valore); 
  
              app.use(function(req, res, next) {
                  res.header("Access-Control-Allow-Origin", "*");
                  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
                  next();
              });
  
              app.get('/valore', function(req, res){
              res.json({ livello: json[11].valore }); 
              });     
          }
     });
  }
  </code></pre>
  
  <p>I want to run that function every 10 minutes, i have looked at setInterval but when i replace this:</p>
  
  <pre><code>ricarica();
  </code></pre>
  
  <p>with this:</p>
  
  <pre><code> setInterval(function() {
       ricarica();
   }, 600000);
  </code></pre>
  
  <p>When I ask for the data from my website, with the first I can see the data but It is not updated, with the second one I have the message"Cannot GET /valore";</p>
  
  <p>How can i fetch data and update every 10 minutes? </p>