title: Node.js pass GET value to socket.io?
body: <p>I want to pass GET value from URL to socket.io so it can emit to front-end.
  I have this:</p>
  
  <pre><code>app.get('/data/', function (req, res) {
    var queryData = url.parse(req.url, true).query;
    res.send('Temp: '+queryData.temp);
    var temp = queryData.temp; //&lt;= this value I want to send
  }); 
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>io.sockets.on('connection', function (socket) {
  socket.emit('message', temp); //&lt;= here I want to put data
  });
  </code></pre>
  
  <p>Idea is: make GET requests with some value (example.com/data/?temp=22), pass that value to index.html in real-time (so I can put in graph).</p>
  
  <p>EDIT:
  I have semi-working solution:</p>
  
  <pre><code>io.sockets.on('connection', function (socket) {
  
      app.get('/data/', function (req, res) {
  
        var queryData = url.parse(req.url, true).query;
        res.send('Temp: '+queryData.temp);
        var temp = queryData.temp;
  
      socket.emit('message', temp);
  
      }); //app.get data
  });
  </code></pre>
  
  <p>This working form time to time, not always. Sometime works great, sometime not at all. But it is what I want... only to work always.</p>