project_mern_memories
project_mern_memories copied to clipboard
Updated index.js file with configureStore()
Hi, thought I'd contribute this project by refactoring client/scr/index.js to use configureStore() method instead of createStore() method.
I've added another change without creating a separate branch.
Change based on the following error: TypeError: PostMessage.findByIdAndRemove is not a function
Fix: Update findByIdAndRemove(id) with findByIdAndDelete(id)
Location: server/controllers/post.js - deletePost()
Code Snippet:
export const deletePost = async (req, res) => {
const { id } = req.params;
if (!mongoose.Types.ObjectId.isValid(id))
return res.status(404).send(`No post with id: ${id}`);
await PostMessage.findByIdAndDelete(id); **<== Fix ===>**
res.json({ message: "Post deleted successfully." });
}