Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

510
Vistas
JavaScript websocket.emit TypeError: socket.emit is not a function

I would like to emit special event from client side to server. I created a code like this :

const socket = new WebSocket('ws://localhost:9090');

let set_nickname = message => {
    socket.emit ("type-event",message)
}

It throws an error:

Uncaught TypeError: socket.emit is not a function

I couldn't find a solution due to this problem (I'm not sure if emit is even implemented in websocket, I couldn't find a method in a specification, but webstorm suggests that I could use this).

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The .emit() is a part of Socket.IO but you are using WebSocket API in a browser that uses .send() to emit data to server.

const socket = new WebSocket('ws://localhost:9090');

socket.send("Hello server!");
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda