diff --git a/src/routes/pokemon.js b/src/routes/pokemon.js index 8845b1d..b41dc35 100644 --- a/src/routes/pokemon.js +++ b/src/routes/pokemon.js @@ -31,8 +31,10 @@ router.get("/name/:name", function (req, res, next) { /* GET Pokemon by Type */ router.get("/type/:type", function (req, res, next) { - // TODO: Implement this route. See swagger docs for details, by visiting http://localhost:3000/api-docs - res.status(501).json({ message: "Not Implemented" }); + const qType = req.params.type.toLowerCase(); + const searchResults = pokedex.filter(pokemon => pokemon.type.find(type => type.toLowerCase() === qType)); + if (searchResults) res.status(200).json(searchResults); + else res.status(404).json({ error: "Not found" }); return; });