ambelovsky / koa-socket-2

Socket.IO for Koa
https://www.npmjs.com/package/koa-socket-2
98 stars 14 forks source link

How can I to get a io? #19

Open HulioEglesias opened 5 years ago

HulioEglesias commented 5 years ago

I want to get created io from other file. socket.js

const IO = require( 'koa-socket-2' );
const io = new IO();

module.exports = {
  io
}

File where I want to get access to io:

const io = require('./socket').io;

But io is undefined, and require('./socket') is {}

jockehewh commented 4 years ago

when you export IO with the brackets you have to import it with the brackets like so: const { io } = require('./socket')