Answers for "import socket from socket-io"

1

socket.io client send data node js server

var socket = io.connect('http://localhost');
socket.emit('my other event', { my: 'data' });
//server side
io.sockets.on('connection', function (socket) {
  socket.on('my other event', function (data) {
    console.log(data);
  });
});
//sending data from the user via a socket.io
socket.on("test", function (data) {
    data.forEach(obj => {
        console.log("Yer : " + obj.yer + ", Lat : " + obj.lat + ", Long : " + obj.lng);
    })
});
Posted by: Guest on November-28-2020
0

angular socket.io with token header

var socket = io("http://localhost", {
  extraHeaders: {
    Authorization: "Bearer authorization_token_here"
  }
});
Posted by: Guest on August-24-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language