Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
Prompt not taking user input from client side

Hey Stack Overflow geeks, I'm working on a real-time chat application using HTML, CSS, and js using socket.io. There I've been created an index.js file that stores the user information and strikes back the same and the other one named client.js which takes the name of the user using prompt. Both of the files has been given below

index.js

const io = require('socket.io')(5000)
const users = {};
io.on('connection', socket =>{
    socket.on('new-user-joined', user =>{
        console.log("New user", user)
        users[socket.id] = user;
        socket.broadcast.emit('user-joined', user);
    });
    socket.on('send', message=>{
        socket.broadcast.emit('receive', {message: message, name: users[socket.id]})
    });
})

client.js

const socket = io('https://localhost:5000');
const form = document.getElementById('send-container');
const messageIn = document.getElementById('messageIn');
const messageContainer = document.querySelector('.container');
const user = prompt("Enter your username")
socket.emit('new-user-joined', user);

Now the problem is that the client.js file didn't fire up the prompt for taking user input. Since I'm currently in the learning phase of web development I tried my best to know where am I getting wrong but didn't find the appropriate solution. Please help me to get to know where am I going wrong.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda