Skip to content

Instantly share code, notes, and snippets.

@donnfelker
Created June 27, 2012 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donnfelker/3006934 to your computer and use it in GitHub Desktop.
Save donnfelker/3006934 to your computer and use it in GitHub Desktop.
Express 3 Changes in res.json
// v0.6.19 way of returning JSON.
exports.index = function(req, res) {
Workout.find({}, function(err, docs) {
if(!err) {
res.json( { workouts: docs }, 200);
} else {
res.json( { message: err }, 500);
}
});
}
// v0.8.0 way of returning JSON, note the change of order of params
exports.index = function(req, res) {
Workout.find({}, function(err, docs) {
if(!err) {
res.json(200, { workouts: docs });
} else {
res.json(500, { message: err });
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment