@@ -7,6 +7,18 @@ router.get("/", function (req, res, next) {
77 res . json ( pokedex ) ;
88} ) ;
99
10+ /* GET Pokemon by English Name */
11+ router . get ( "/name/:name" , function ( req , res , next ) {
12+ // TODO: Implement this route. See swagger docs for details, by visiting http://localhost:3000/api-docs
13+
14+ const name = req . params . name ;
15+ const pokemon = pokedex . find ( p => p . name . english === "Pikachu" ) ;
16+ if ( ! pokemon ) {
17+ return res . status ( 404 ) . json ( { error : "Pokemon not found" } ) ;
18+ }
19+ res . json ( pokemon ) ;
20+ } ) ;
21+
1022/* GET Pokemon by Id. */
1123router . get ( "/:id" , function ( req , res , next ) {
1224 // TODO: Implement this route. See swagger docs for details, by visiting http://localhost:3000/api-docs
@@ -23,17 +35,7 @@ router.get("/:id", function (req, res, next) {
2335 return ;
2436} ) ;
2537
26- /* GET Pokemon by English Name */
27- router . get ( "/name/:name" , function ( req , res , next ) {
28- // TODO: Implement this route. See swagger docs for details, by visiting http://localhost:3000/api-docs
29-
30- const name = req . params . name ;
31- const pokemon = pokedex . find ( p => p . name . english === "Pikachu" ) ;
32- if ( ! pokemon ) {
33- return res . status ( 404 ) . json ( { error : "Pokemon not found" } ) ;
34- }
35- res . json ( pokemon ) ;
36- } ) ;
38+
3739
3840/* GET Pokemon by Type */
3941router . get ( "/type/:type" , function ( req , res , next ) {
0 commit comments