-
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
Happy Thoughts API by Joyce Kuo #511
base: master
Are you sure you want to change the base?
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 💯
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 that you broke out the model 👍 Can be nice for the final project as well, when your project will be bigger
const newThought = await new Thought({ message }).save(); | ||
|
||
// Send success response with saved thought | ||
res.status(201).json({ | ||
success: true, | ||
response: newThought, | ||
message: "Thought was successfully created!", | ||
}); | ||
} catch (error) { | ||
res.status(400).json({ | ||
success: false, | ||
response: error.message, | ||
message: "Failed to create thought", | ||
}); | ||
} |
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 structure 😉
const updatedThought = await Thought.findByIdAndUpdate( | ||
thoughtId, | ||
{ $inc: { hearts: 1 } }, // Increment the hearts field by 1 | ||
{ new: true } // Return the update | ||
); |
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.
⭐
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.
Can you please change the fetch URL in your frontend 😇
Fetch URL should now be updated. Thank you ! 😊 |
Render link
https://project-happy-thoughts-api-ph1w.onrender.com/
Netlify link
https://happy-thoughts-joyce.netlify.app/