score:1

the first error is because you are not requiring express:

var express = require('express');

and to use express router, you'd want to declare the router, define the routes using it and then import the route file to use as middleware.

you could make a separate user routes file:

var express = require('express');
var router = express.router();

router.get("/", function(req, res) {
   //route actions

});

...

module.exports = router;

and then import it and use it in your server.js file like so:

var userroutes = require('./userroutespath')

app.use("/users", userroutes);

hope this helps.


Related Query

More Query from same tag