Open
Conversation
HIPPIEKICK
previously requested changes
Dec 18, 2024
Contributor
HIPPIEKICK
left a comment
There was a problem hiding this comment.
Code looks good, just need to see a working deploy! Let us know if you need help debugging
|
|
||
|
|
||
| // Ge books based on number of pages (needs to be befor bookID otherwise that route will override this) | ||
| app.get("/books/pages", async (req, res) => { |
Contributor
There was a problem hiding this comment.
This could be named just /books, because that's what this endpoint is returning
Comment on lines
+116
to
+133
| app.get("/books/authors/:author", async (req, res) => { | ||
| const author = req.params.author; | ||
|
|
||
| try { | ||
| // $regex = to match name and not case sensitive | ||
| const booksByAuthor = await Book.find({ | ||
| authors: { $regex: author, $options: "i" }, // "i" case-insensitive | ||
| }); | ||
|
|
||
| if (booksByAuthor.length > 0) { | ||
| res.json(booksByAuthor); // Returnera böckerna om de finns | ||
| } else { | ||
| res.status(404).json({ error: "No books found for this author" }); | ||
| } | ||
| } catch (error) { | ||
| res.status(500).json({ error: "An error occurred while fetching books" }); | ||
| } | ||
| }); |
Contributor
There was a problem hiding this comment.
And this should also be a query under your /books endpoint to make it more RESTful. Even though you're filtering on author, you still return books
Contributor
|
Reach out to us if you need help with the deploy, otherwise, I'll wait for new changes 😊 |
JennieDalgren
approved these changes
Jan 25, 2025
Contributor
JennieDalgren
left a comment
There was a problem hiding this comment.
Yes! deployad och funkar. Snyggt jobbat. 💪
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
https://project-18-mongo-api.onrender.com/ (not working yet..)
Collaborators