0

I'm trying to make a function call inside my module but I'm getting functionTwo is not define.

Module.js

// Module.exports
module.exports = function ( arg ) {

if(arg instanceof Object) {

    return functionTwo.apply(arg);
}

 functionOne: function(arg) {}

 functionTwo: function(arg) { //in here we may call functionOne or functionThree }

 functionThree: function() {}

Main.js

require(module)(typeObject);
require(module)(typeString);

So basically what I'm trying to do is if the type that is being passed from main.js to the module.js was an Object I want it to call a specific function and do something then just return, but I don't know maybe I'm defining the function wrong.

3
  • 1
    Your snippet is invalid JS. Can you please post real code? Mostly, what object are functionOne and such part of? Commented May 19, 2013 at 16:56
  • @loganfsmyth it's the module from here github.com/mozilla/node-webmaker-loginapi/blob/master/index.js. I want to create something like if the app.get( "/user/:userid", function( req, res ) { get fired will call one of the function inside the module.
    – Ali
    Commented May 19, 2013 at 16:59
  • @loganfsmyth say when I do the require from the main.js and if the url that is entered localhost:3000/user/:userid will call some function in the module, but I can't figure out why I can do that.
    – Ali
    Commented May 19, 2013 at 17:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.