I'm newish i want to get to my app.js from a search.js an object. Inside the module works fine but when i acces from outside i get undefined value app.js
const search = require(__dirname + "/search.js");
app.get("/", function(req, res) {
var list = search.foundType(TypeProduct);
console.log(list);
res.render("home",{listType: list});
});
search.js
exports.foundType = function(TypeProduct) {
TypeProduct.find({}, function(err, listOfProduct) {
if (!err) {
if (listOfProduct) {
return listOfProduct;
}
} else {
console.log(err);
}
});
}
I will appreciate the help.