javascript - node.js export module function -
i have problem node.js. creating blog , have 2 archives: sessions.js users.js
in sessions.js :
function sessionsdao(db) { this.startsession = function(username, callback) {....} } module.exports.sessionsdao = sessionsdao;
in users.js
var session = require('./sessions'); var s = new session(); s.startsession(username);
but shows me error:
object not function typeerror: object not function
require
returns exports
object, so:
var sessionsdao = require('./sessions').sessionsdao; var s = new sessionsdao(); s.startsession(username);
Comments
Post a Comment