0

I have a routes.js file that looks like this.

return {
  "GET" : {
    "/" : renderHomePage
  },
  "POST" : {
    "/ajax/addUser" : addUser
  }
}

I am trying to include it in the main create server script so that I can access it directly inside the variable to call the functions.

var routes = require("routes.js");
    var internalFunction = routes.GET["/"];
        internalFunction();

It isn't working but I was wondering how I can do this?

1 Answer 1

4

instead of using "include", try this:

var routes = require("routes.js");
Sign up to request clarification or add additional context in comments.

1 Comment

hi sorry that was a typo just in the example code, not in the real application.

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.