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

router.get('/', function(req, res, next){
res.send('INDEX PAGE');
});

module.exports = router;

I keep getting this error, I've even downgraded my express to V3.21.

TypeError: Cannot read property 'get' of undefined

2 Answers 2

3

The Express V3.X API reference doesn't have express.Router. API Reference

Sign up to request clarification or add additional context in comments.

Comments

0

Do this instead

var express = require('express');
var app= express();

app.get('/', function(req, res, next){
res.send('INDEX PAGE');
});

module.exports = app;

Comments

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.