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

Anna's Happy Thoughts API #502

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

Conversation

Anna2024WebDev
Copy link

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.

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 });
Copy link
Contributor

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}`);
Copy link
Contributor

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
Copy link
Contributor

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.

@Anna2024WebDev
Copy link
Author

Thanks for your feedback @HIPPIEKICK console logs removed and findByIdAndUpdate- according to mongoose method is now updated.

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