Reputation: 141
in server.js
var connect = require('connect');
var http = require('http');
function doFirst(request, response, next) {
console.log('bacon');
next();
}
function doSecond(request, response, next) {
console.log('tuna');
next();
}
app.use(doFirst);
app.use(doSecond);
var app = connect();
http.createServer(app).listen(8080);
after running it says cannot read property 'use', i already installed package connect, and already initialize the app also can anyone help me out?
Upvotes: 2
Views: 1343
Reputation: 53958
You should first declare the app
:
var app = connect();
and then call the use
method.
app.use(doFirst);
app.use(doSecond);
Upvotes: 6