Omdat getAllProductListings
asynchroon is, moet u het antwoord in de callback verzenden:
// Get latest listings
router.get('/latest/all', function (req, res, next) {
Product.getAllProductListings(res);
});
En in uw product.js
:
//Find All
module.exports.getAllProductListings = function (response) {
var query = {};
Product.find(query, function (err, docs) {
console.log(docs);
response.send(docs);
});