U
U
user_of_toster2021-06-12 12:16:10
Node.js
user_of_toster, 2021-06-12 12:16:10

How does import\export work?

sockets.js (example taken from here )

import WebSockets from "ws";

const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
    console.log('received: %s', message);
  });

  ws.send('something');
});

export {
    wss
}

index.js
import {wss} from './sockets';
How to explain that the server continues to process requests if it is launched through node sockets, but if node indexit is not launched through ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-06-12
@bingo347

https://nodejs.org/dist/latest-v16.x/docs/api/esm....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question