Saturday 18 March 2017

how to include js file with no error?

i want to separate my route file in nodejs

i use restify framework and this is part of my code

app.routes((app)=>{
  require(__dirname + '/../routes/web.js')
})

routes/web.js

app.get('/', function (req, res, next) {
    console.log("object");
})

when run the program i get this error

app is not a defined

who can i fix that??

in web.js "app" is undefined while i sended it to function



via Armin kheirkhahan

No comments:

Post a Comment