Rather than using request, to handle the code from the browser side, I have opt for import. Now the following line is buggy, I get from it Unexpected token '('
import io from "socket.io"(server, {something});
Here is more Code to compare.
import express from 'express';
import http from 'http';
var app = express();
var server = http.createServer(app);
import io from "socket.io"(server, {
cors: {
origin: "http://example.com",
methods: ["GET", "POST"],
allowedHeaders: ["my-custom-header"],
credentials: true
}
});