Build a Real Time Chat App With Node.js And Socket.io
Why Stack Overflow recommends it
Stack Overflow users link it as the tutorial they followed when asking why their Socket.io chat code hits CORS errors, null messages or a 404 on localhost.
Recommended by 0 people across 0 different months, 2020 to 2021.
What it is
A 17-minute tutorial from Web Dev Simplified that builds a real-time chat app in under 100 lines of JavaScript. It uses Node.js and Socket.io to handle usernames, connect and disconnect messages, and broadcasting chat messages to all connected clients.
What people said
Cites gazeboextreme · 2020-07 · Stack Overflow · on “Socket.io messages returning as "null"”
I'm working on a simple chat application in socket.io and I'm currently running the files in a local server. In my "script.js" file I have the following: const socket = io(' [LINK] ') const messageForm = document.getElementById('send-container') const messageInput = document.getElementById('message-input') socket.on('chat-message', data => { console.log(data) }) messageForm.addEventListener('submit', e => { e.preventDefault() const message = messageInput.Value socket.emit('send-chat-message', message) messageInput.value = '' }) And in my "server.js" file I have the following: const io = require('socket.io')(3000) io.on('connection', socket => { socket.emit('chat-message', 'Hello World') sock
Cites The Tiger · 2020-12 · Stack Overflow · on “Node js, socket.io after fixing cors error I get a new error that I can't fix”
I'm new to web development, javascript, and node js. I know that there are a lot of questions on the cors error already I have spent 2 days looking at solutions to my problem but I can't figure out how to solve this cors error. yesterday after 2 days of searching I finally found a solution that worked at first but now it only works 20% of the time and the other 80% I get another error. I set up my socket.io and tried to send sockets through socket.io exactly as shown in this youtube video: [this video] Although my code was exactly the same as in the video I kept getting a cors error when sending sockets. Here is some of my server-side code: const io = require("socket.io")(3000); var fs = require(
Cites Chlodio · 2021-06 · Stack Overflow · on “Socket.io can't find localhost”
I was following this basic tutorial [this video] , when I quickly found out that socket.io doesn't seem to detect my index.html and localhost gives error message 404. So maybe I had mistyped something, thus I copied the files [LINK] from the tutorial, but the same issue persists. What am I missing?