Goal: I'm trying to find a way to let a user sort rentals by max and min price on the one index page.
My problem is the only way I could figure out how to make it work was to create two separate pages specifically for lowprice and highprice. I want to only have one main index.
The pricelow page shown below filters the data from low to high prices
app.get("/pricelow", function(req, res){
Listings.find({}).sort({price: 1}).exec(function(err, allListings){
if(err){
console.log(err);
} else {
res.render("pricelow",{listings:allListings});
}
})
});
//The pricehigh page shown below filters the data from high to low prices
app.get("/pricehigh", function(req, res){
Listings.find({}).sort({price: -1}).exec(function(err, allListings){
if(err){
console.log(err);
} else {
res.render("pricehigh",{listings:allListings});
}
})
});