Project express api - deployed on Render - Emelie Nyberg#521
Open
EmelieNyberg wants to merge 4 commits intoTechnigo:masterfrom
Open
Project express api - deployed on Render - Emelie Nyberg#521EmelieNyberg wants to merge 4 commits intoTechnigo:masterfrom
EmelieNyberg wants to merge 4 commits intoTechnigo:masterfrom
Conversation
HIPPIEKICK
approved these changes
Dec 10, 2024
Contributor
HIPPIEKICK
left a comment
There was a problem hiding this comment.
Great job on creating your first RESTful API! You've done some nice filtering, just remember that sorting can be included as a query param as well (to keep it more RESTful).
Keep up the good work!
Comment on lines
+60
to
63
| app.get("/videogames/sorted/ratings", (req, res) => { | ||
| const sortedGames = videogames.sort((a, b) => b.rating - a.rating); | ||
| res.json(sortedGames); | ||
| }); |
Contributor
There was a problem hiding this comment.
This could be another query param: ?sortOnRate=descending or something
Comment on lines
+22
to
+43
| app.get("/videogames", (req, res) => { | ||
| const category = req.query.category; | ||
| const year = req.query.year; | ||
|
|
||
| // Filter on category if category is sent | ||
| // For example http://localhost:3000/videogames?category=racing | ||
| if (category) { | ||
| const filterCategory = videogames.filter(game => game.category.toLowerCase() === category); | ||
| res.json(filterCategory); | ||
|
|
||
| // Endpoint that returns a specific year | ||
| // For example http://localhost:3000/videogames?year=2020 | ||
| } if (year) { | ||
| const videogameByYear = videogames.filter(game => game.release_year === +year); | ||
| res.json(videogameByYear); | ||
|
|
||
| // If no categori is sent, return all videogames | ||
| // For example http://localhost:3000/videogames | ||
| } else { | ||
| res.json(videogames); | ||
| }; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Render link
https://project-express-api-ek.onrender.com