I am facing an error in my node.js code.
Error: /workspace/Ap/node_modules/express/lib/router/index.js:252
throw new Error(msg);
^
Error: .get() requires callback functions but got a [object Undefined].
Yesterday my code was working fine but today with same code i face above error, and I don't get where is the problem. My code is:
app.js
var express = require('express');
var routes = require('./routes');
var http = require('http');
var path = require('path');
var app = express();
var mysql = require('mysql');
routes/index.js
module.exports = function(req, res){
res.render('index', { title: 'Express' });
};
Thanks..
Take a look at where you define a GET route, likely at line 252 or thereabouts.
To process a GET in your framework, a callback must be supplied. Currently, your code is supplying [object Undefined], which likely means your object, or exports or whatever is filling that function parameter isn't what you think it is! : )