Skip to content

Node.js, MongoDB, Express and Sessions: TypeError: Object #Object> has no method ‘bodyDecoder’

by Beni on März 14th, 2011

I just struggled with this error message whilst trying to set up some sort of authentication layer for a small node.js-powered web application with a MongoDB backend. This was my code to establish a MongoDB session handling. The TypeError: Object #<Object> has no method 'bodyDecoder' occurs in line 5 of the following snippet:

1
2
3
4
5
6
7
8
9
10
11
var MongoStore = require('connect-mongodb');
app.use(express.logger({ format: ':method :url'}));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieDecoder()); // <= runtime error appears here
app.use(express.session({
	secret: settings.cookie_secret,
	store: new MongoStore({
		db: settings.db
	})
}));

After some investigation I found out that in Express 2.0.0beta3, the function cookieDecoder() has been renamed to cookieParser(); the same comes true for bodyDecoder() which now needs to be called as bodyParser(). At least now I know why some of the example code failed ;-)

Das wird dich vielleicht auch interessieren:

2 Comments
  1. thanks

Trackbacks & Pingbacks

  1. RegioVelo – Endlich Fertig! ~>

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS