Having a bit of code here
// Script for retrieving pokedex data
app.get("/pokedex", function (req, res) {
Pokemon.find(function (err, pokemon) {
if (err) {
console.log(err);
} else {
console.log(pokemon);
res.render("pokedex", { pokemon: pokemon });
}
});
});
The above code successfully sends the data to the frontend and logs it correctly. However, when trying to add
{ information: { primaryType: "Grass" } },
before the callback, no data is sent. Instead, only empty arrays are logged, even though I'm attempting to filter the data.
I am utilizing JS, Node, Express, and EJS for this task. Any suggestions on alternative methods for filtering the data would be appreciated.
Model
[
{
information: {
name: 'Bulbasaur',
dexNumber: 1,
primaryType: 'Grass',
secondaryType: 'Poison',
description: 'There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger.',
devolvedForm: null,
evolvedForm: 'Ivysaur'
},
stats: {
health: 45,
attack: 49,
specialAttack: 65,
defense: 49,
specialDefense: 65,
speed: 45
},
_id: 609cdab515102582ccf4e743,
__v: 0
},