Sorry to bring up this here. I couldn't find any information of importing it in ES6 syntax. Is it supported now? Do I have to use require('socket.io-client')
? If I use import * as io from 'socket.io-client'
I have to use io.connect('localhost')
. But if I use require('socket.io-client')
I just need to use io('localhost')
.
Doing import io from 'socket.io-client'
will give you a direct reference to io
.
import ioClient from 'socket.io-client'
let io = ioClient('http://your-host')
how do you pass options in this case?
Try doing something like this:
`import express from 'express';
import http from 'http';
import SocketIO from 'socket.io';
import compression from 'compression';
import {validNick, findIndex, sanitizeString} from '../shared/util';
let app = express();
let server = http.Server(app);
let io = new SocketIO(server);`
Importing doesnt work. It says fetch module import failed
Most helpful comment
Doing
import io from 'socket.io-client'
will give you a direct reference toio
.