Answer the question
In order to leave comments, you need to log in
Why is my js code not working on node?
Don't drink noob. Code in myserver/client.js file
var socket = new WebSocket("wss://stream....блабла");
socket.onopen = function() {
console.log("Соединение установлено.");
};
node myserver/client.js
I get an error Error: WebSocket is not defined
Answer the question
In order to leave comments, you need to log in
I think I found the reason - Node.js does not have a built-in WebSocket constructor (unlike browsers), so you need to install a third-party websocket package. https://github.com/vitalets/websocket-as-promised/... Nevertheless, I would be grateful if someone supplements this topic with their information.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question