I am able to get the room name from user but as I use `module.exports` in another file to retrieve it shows undefined . This might be because it is asynchronous. 

//roomcheck.js

```
var nsp = io.of("/gameroom");
nsp.on('connection', (socket) => {
socket.on('check', (data) => {
    if (rm.includes(data)) {
        roomname = data;
        console.log(roomname);
        console.log("Room exist!!!");
        socket.emit('success', 'room already made');
});

module.exports=roomname;

```

//userpage.js

```
var r=require('roomcheck.js');
console.log(r.roomname);

```

**Expected** - roomname entered by user.

**My output** - undefined