node.js - exporting a module in a callback function? -


Is there a way to export some variables inside a callback function? For example, if I want to use room.room_id in any other file, what should I do? I tried the module Exports room id = room. Room_id but the room appears to be undefined in another file. Thanks!

  var needs room = ('../method/database'). Cell Export .create = function (req, res) {room .create ({room_name: req.body.roomName}) .complete (function () (room .find ({where: {room_name: req.body.roomName}} Success. (Work (room) {// if (err) console.log (err); res.redirect ('rooms / videochat /' + req.body.roomName + '/' + room.room_id); console Log ("Room_id:" + room.room_id); module.exports.roomId = room.room_id;})})  

};

You can not do this because the modules are evaluating synchronous and you can change module.exports What you need to do is supply a callback and Or the price may have or callback read successfully use as an indicator that you export went home.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -