I need to get the QueryString
being passed to the server created on NodeJS . I've tried it in many ways but I can not get the and ph parameters. I am a beginner in NodeJS and the code I have is:
var express = require('express')
, app = express()
, fs = require('fs')
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)
;
app.use(express.static(__dirname + '/'));
var porta = 3000;
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html')
});
io.on('connection', function(socket){
result = {
ph: Math.random() * 100,
DO: Math.random() * 100
}
/*socket.emit('dados', {
valor: result
});*/
socket.broadcast.emit('dados', {
valor: result
});
});
server.listen(porta, function(){
console.log("Servidor rodando na porta "+porta+". Aperte CTRL+C para finalizar a conexão.");
});
I need to get this data that is going to be passed by QueryString and play in json
result instead of Math.random() * 100