-
Notifications
You must be signed in to change notification settings - Fork 529
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
base: master
Are you sure you want to change the base?
Books API #519
Conversation
There was a problem hiding this 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!
app.get("/books/popular", (req, res) => { | ||
const popularBooks = booksData.filter(book => book.average_rating && parseFloat(book.average_rating) > +4) | ||
res.status(200).json(popularBooks) | ||
}); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! ⭐
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") | ||
} | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐
Congrats Gitte! Really good job with the nice, clean and super-easy-to-follow code! I learn a lot from your code. |
https://project-express-api-17pi.onrender.com