Answer the question
In order to leave comments, you need to log in
Can't get an object in another file?
I am trying to access socket instance from another
socket.js file
const IO = require( 'koa-socket-2' );
const io = new IO();
module.exports = {
io,
}
const io = require('./../socket').io;
console.log(io); // undefined
Answer the question
In order to leave comments, you need to log in
Try like this:
const IO = require( 'koa-socket-2' );
const io = new IO();
module.exports = {
io: io,
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question