-
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
Jonas Happy thoughts api #510
base: master
Are you sure you want to change the base?
Conversation
…s, using MongoDB for data storage. Deployed the backend to Render with MongoDB Atlas for remote database access, while maintaining local development support.
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 Jonas, keep it up 💯
const updatedThought = await Thought.findByIdAndUpdate( | ||
thoughtId, | ||
{ $inc: { hearts: 1 } }, | ||
{ new: true } // Return the updated document |
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.
⭐
if (!updatedThought) { | ||
return res.status(404).json({ | ||
success: false, | ||
message: "Thought not found.", | ||
}); | ||
} | ||
|
||
res.status(200).json(updatedThought); | ||
} catch (error) { | ||
res.status(400).json({ | ||
success: false, | ||
message: "Could not add like.", | ||
error: error.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 error handling 👍
Backend: https://project-happy-thoughts-api-b7a3.onrender.com/thoughts
Frontend URL: https://jonas-happythought.netlify.app/