I am using nodejs and express for api end points, I am using app.use
to handle a route, but it is not responding no matter what I do.
var express = require("express");
var mongoose = require('mongoose');
var path = require("path");
var favicon = require("serve-favicon");
var http = require('http');
var app = express();
var config = require('./conf/config');
var PORT = config.PORT;
mongoose.connect(config.MONGODB);
//route handlers
app.use('/', function(req, res) {
console.log("Hello");
});
var server = http.createServer(function(req, res) {
console.log("Request received", req.url);
});
server.listen(PORT);
console.log("Server running on port", PORT);
It should print hello on console whenever I request on root route i.e. /
but it's not doing anything.
via Girdhari Agrawal
No comments:
Post a Comment