Quiero recibir notificaciones del back-end usando sockets y para recibir estas notificaciones debe estar autenticado. Lo que significa que debe pasar el token con los sockets para recibir notificaciones del back-end. Aquí está el código que escribí:
const headers = { Authorization: "bearer " + this.authService.getToken() }; const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'; const endpoint = protocol +'localhost:8000/channel/on/notification/'; const socket = new WebSocket(endpoint, ['access_token',this.authService.getToken()]); socket.onopen = function (e) { console.error('WebSockets connection created.'); }; socket.onmessage = function (e) { const data = JSON.parse(e.data); console.log(data) }; socket.onclose = function (e) { console.log('Chat socket error ===>>', e) }; }Todavía sigo recibiendo errores. ¿Alguna ayuda?