samedi 18 avril 2015

node.js and socket.io: How can I get a specific query string?

This is my nodejs-server-code:



io.sockets.on('connection', function(socket) {
var parts = require('url').parse(socket.handshake.url,true).query;

console.log('url: ' + parts);


Console prints [object Object]. If I JSON.stringify(parts) I get the data, but how can I get the value of a specific query-string like id?


Also why do I just got a url result like this from socket.io and not the one from my localhost page? /http://ift.tt/1EVC1b3


Aucun commentaire:

Enregistrer un commentaire