I'm a newbie to NodeJS and REST and I'm experimenting how to write a simple REST API. I came across with the following segment of code. I understand the meanings of req and res, but I'm not sure about next. Also, is the next in the parameter same as the next() method? Hope someone can help me clarify. Thank you.
function findAll(req, res , next){
db.productinfo.find(function (err, productinfo) {
res.writeHead(200, {
'Content-Type': 'application/json; charset=utf-8'
});
res.end(JSON.stringify(productinfo));
});
return next();
Aucun commentaire:
Enregistrer un commentaire