0

throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn)) ^

TypeError: Router.use() requires a middleware function but got a Object

everytime I try to run my web app, it appears that I get an error i'm not sure what i'm missing. Very new to node I've linked my github.

https://github.com/kamrantrea/serverSide2019-/issues/1

the issue is in my assignments folder, i'm hoping someone can help me see where I am going wrong.

Kam
  • 44
  • 7
  • Possible duplicate of [TypeError: Router.use() requires middleware function but got a Object](https://stackoverflow.com/questions/27465850/typeerror-router-use-requires-middleware-function-but-got-a-object) – mexo Feb 28 '19 at 01:26

1 Answers1

0

Check these lines of your code.

var index = require('./routes/index');
app.use('/', index);

The viable index should return a function instead you are not exporting anything. The index should retrieve a function like this

function (req, res, next) {
  // some logic
  next()
}
TRomesh
  • 4,323
  • 8
  • 44
  • 74