Skip to content

Anna's Happy Thoughts API#502

Open
Anna2024WebDev wants to merge 9 commits intoTechnigo:masterfrom
Anna2024WebDev:master
Open

Anna's Happy Thoughts API#502
Anna2024WebDev wants to merge 9 commits intoTechnigo:masterfrom
Anna2024WebDev:master

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