-
-
Save awsvpc/c6d28e12378344cf857d4c36e8683354 to your computer and use it in GitHub Desktop.
Websocket node js client Authorization Bearer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocket = require('websocket').w3cwebsocket; | |
var token = "key-token"; | |
const socket = new WebSocket('ws://localhost:8000/ws', null, null, { | |
Authorization: `Bearer ${token}` | |
}); | |
socket.onopen = () => { | |
console.log('WebSocket connection established'); | |
}; | |
socket.onmessage = (event) => { | |
console.log('WebSocket message received', event.data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment