Skip to content

Commit 6fcf15e

Browse files
Nisreen OweidatNisreen Oweidat
authored andcommitted
Implemented Pokemon API fixes and enhancementss
1 parent 86268a2 commit 6fcf15e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6-
"start": "node ./bin/www",
7-
"start" : "nodemon ./bin/www"
6+
"start": "node ./bin/www"
87
},
98
"dependencies": {
109
"cookie-parser": "~1.4.4",

src/routes/pokemon.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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. */
1123
router.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 */
3941
router.get("/type/:type", function (req, res, next) {

0 commit comments

Comments
 (0)