project-express-api - Elina Eriksson Hult#523
Open
ElinaEH wants to merge 8 commits intoTechnigo:masterfrom
Open
project-express-api - Elina Eriksson Hult#523ElinaEH wants to merge 8 commits intoTechnigo:masterfrom
ElinaEH wants to merge 8 commits intoTechnigo:masterfrom
Conversation
HIPPIEKICK
approved these changes
Dec 10, 2024
Contributor
HIPPIEKICK
left a comment
There was a problem hiding this comment.
Good job Elina with your first API! Just remember going forward that all endpoints should be named after what they return and that you can make use of query params
| }); | ||
|
|
||
| // Function to filter books by their language | ||
| const filterBooksByLanguage = (req, res) => { |
Contributor
There was a problem hiding this comment.
Nice that you broke this out!
| }; | ||
|
|
||
| // Endpoint to fetch books filtered by language | ||
| app.get("/books/language", filterBooksByLanguage); |
Contributor
There was a problem hiding this comment.
It would be more RESTful if this was a query param in the /books endpoint instead of its own endpoint, e.g. /books?language=english
Comment on lines
69
to
75
| app.get("/", (req, res) => { | ||
| res.send("Hello Technigo!"); | ||
| const endpoints = listEndpoints(app); // Fetch all endpoints | ||
| res.json({ | ||
| message: "Welcome to the Book API 📚 Here are the available endpoints:", | ||
| endpoints: endpoints, | ||
| }); | ||
| }); |
Contributor
There was a problem hiding this comment.
I usually order my endpoints from the most general to the most specific. Is there a reason why you put this last? 👀
| } else { | ||
| res.status(404).json({ | ||
| error: `No books found for this language: ${language}`, | ||
| example_usage: "Try this: /books/language?language=spa" |
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.
https://project-express-api-elina.onrender.com