Handle incoming HTTP request with Socket.io in Node js app
<p>I have a node app that should receive request from another app through a HTTP GET request <code>/api/users?data=68</code> and display the data in real time.I have api/users route that handle incoming HTTP request. To start with i have node app that works with socket.io But now i want to handle Http request.Here is my code</p>

<pre><code>    var express = require('express');
    var app = express();
    var server   = require('http').Server(app);
    var io = require('socket.io')(server);
    var port = process.env.PORT || 8080
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    var router = express.Router();

    router.get('/api/users', function(req, res) {
    var query = req.param('data');
    io.emit("chat message","some msg");
    });

    io.on('connection', function(socket){
     console.log('client connected');
     socket.on('pass data from HTTP request to the view', function(data){
     console.log(data);
     });

   });

     app.use(router);

     server.listen(port)
</code></pre>

<p><strong>Client.js</strong></p>

<pre><code> var socket = io();
  socket.on('chat message', function (message) {
    //socket.emit('chat message', { my: 'world' });
    console.log('received ');
    });
</code></pre>

<p>How do i pass data from /api/users/ route to socket connection?Thank you in adavance.</p>