Ask coding questions

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

hi,

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.

Commentshotnewtop
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)