Socket not working

I have created a chat. Everything is working. I can see the page that I wrote when I go to the link. but the thing is that I can’t see the chat that are sent. I don’t know why.

Here, the link: https://replit.com/@AndrewAung11/Chat

Sorry for that, that you can’t edit in spotlight page in replit.

Thank you!

Hello there,

I did not thoroughly go through the code, but this stood out:

if(cht.value.trim()===""||un.value.trim==="")

Also, just for the sake of mentioning, it might help to name the server.js variables better. That is, having global- and block- scoped variables with the same handle can be confusing.

The pattern I am used to is:

const io = require('socket.io')(server);
// To avoid having a global 'socket' variable.

Hope this helps

1 Like

@Sky020 Thanks you! Your suggestions reminds me to check the code from the top to bottom. I checked and change some code and now it works now!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.