Linked Questions

Popular Questions

Node/Express: Adding middleware to router does not load

Asked by At

My router looks like this:

app.get('/getReport', (req, res) => {
    res.send("This is the report");
});

The above router works fine and the browser loads, This is the report

but when I do this:

// Filename: router.js

const getReport = require('./getReportController');

app.get('/getReport', (req, res) => {
    getReport.initial
});

and

// Filename: getReportController.js

exports.initial = (req, res) => {
    res.send("This is the report");
};

It does not work and keep waiting...

What could have gone wrong? My goal is to call the controller components, and then add it to the router end point. There is going to be middleware which I will add once this is resolved.

Related Questions