I tried to emit data from client to server using [socket.io-client][1] and the following code i added in react app.
import io from "socket.io-client";
var socket = io.connect('http://localhost:3002');
socket.emit("room", 'room1');
and in server side followimg code added
const app = express();
const http = require("http").Server(app);
const io = require("socket.io");
var socket = io(http);
socket.on("connection", socket => {
console.log("user connected");
socket.on('room', function(room){
console.log("room", room);
socket.join(room);
});
});
app.listen(3002);
But, i didn't receive any data on server side even socket connection established and emit from server to client is working fine. Thank you [1]: https://www.npmjs.com/package/socket.io-client