So I want to make a web socket client using a VueJs using NuxtJs framework, this is My component
export default {
data() {
return {
connection: null,
}
},
created() {
console.log("Starting connection to WebSocket Server")
this.connection = new WebSocket("wss://echo.websocket.org")
this.connection.onmessage = function(event) {
console.log(event);
}
this.connection.onopen = function(event) {
console.log(event)
console.log("Successfully connected to the echo websocket server...")
}
},
head() {
return {
title: 'Web Socket',
meta: [
{
hid: 'description',
name: 'description',
content: 'Web socket'
}
]
}
}
}
I'm using Ms Edge for the browser, I tried using a vue-native-socket, and other socket package, but still get the same error 'Websocket not defined'