-
Notifications
You must be signed in to change notification settings - Fork 517
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
Anna's Happy Thoughts API #502
base: master
Are you sure you want to change the base?
Conversation
…connected the MONGO URL successfully to MongoDB
…l thoughts, post new thought and like thought and added error handling
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.
Use mongoose methods whenever you can, instead of plain JS. Apart from that - good job!
const { message } = request.body; | ||
|
||
try { | ||
const newThought = await Thought.create({ message }); |
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 👍
server.js
Outdated
/// Like a specific thought | ||
app.post("/thoughts/:thoughtId/like", async (request, response) => { | ||
const { thoughtId } = request.params; // Get the thoughtId from the URL params | ||
console.log(`Received request to like thought with ID: ${thoughtId}`); |
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.
Remove console.logs in production code
server.js
Outdated
console.log(`Received request to like thought with ID: ${thoughtId}`); | ||
|
||
try { | ||
const thought = await Thought.findById(thoughtId); // Find the thought by its ID |
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.
You can use findByIdAndUpdate to update hearts directly instead of fetching, modifying, and saving.
Thanks for your feedback @HIPPIEKICK console logs removed and findByIdAndUpdate- according to mongoose method is now updated. |
Netlify link
https://project-happy-thoughts-api-42bh.onrender.com