Ask coding questions

← Back to all posts
socket.on is not a function
RossJames (271)


I have very little node js experience and need some help why i am getting that error. If you could plz run the code to see the error and give some advice, it would be appreciated.

RossJames (271)

@geocube101 Do you have any ideas? Almost got the kick command working.

Geocube101 (588)

Found the problem.
On line 85 }); needs to be moved to line 114. The reason for the error is because your event handlers were outside of the connection handler. As a result, the socket object was not the clients socket, but what you set it to on line 3 (which has no method call on)