9 lines
246 B
JavaScript
9 lines
246 B
JavaScript
const url = location.origin.replace(/^http/, 'ws') + '/api'
|
|
console.log("Connecting WebSocket...", url)
|
|
const ws = new WebSocket(url)
|
|
ws.onmessage = console.log
|
|
ws.onopen = () => {
|
|
ws.send('Hello from the client!')
|
|
}
|
|
ws.onerror = console.error
|