Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Books API #519

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Books API #519

wants to merge 5 commits into from

Conversation

gittebe
Copy link

@gittebe gittebe commented Dec 5, 2024

Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done Gitte! Your API is RESTful (however, I would put the popular filter on the /books endpoint as well, but given you had two other query params there, I see you get the concept) and well-documented.

Keep up the good work!

Comment on lines +26 to 29
app.get("/books/popular", (req, res) => {
const popularBooks = booksData.filter(book => book.average_rating && parseFloat(book.average_rating) > +4)
res.status(200).json(popularBooks)
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a query param: ?popular=true

});

// author and title
app.get("/books", (req, res) => {
const { title, author } = req.query;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! ⭐

Comment on lines +60 to +70
app.get("/books/:isbn", (req, res) => {
const isbn = req.params.isbn
const book = booksData.find(book => book.isbn === +isbn)
res.json(book); {
if (book) {
res.status(200).json(book)
} else {
res.status(404).send("no book found with that ISBN")
}
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Maryyy-ux
Copy link

Congrats Gitte! Really good job with the nice, clean and super-easy-to-follow code! I learn a lot from your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants