0

I need help when clicking on my icon the corresponding message deletes it I can't get my route to work on the front side

mon code front

const handleTrash = (id) => {
    fetch(`http://localhost:3000/deleteTweet/${id}`, {
      method: "DELETE",
      // headers: { "Content-Type": "application/json" },
      // body: JSON.stringify({ id: tweet._id }),
    }).then((response => response.json()) => {
      console.log(response.status);
    });
    // .then((response) => response.json())
    // .then((data) => {
    //   console.log("data is", data);
    // })
    // .then((response) => response.json())
    // .then((data) => {
    //   setTrash(!trash);
    //   console.log("Delete :", reponse);
    // });
  };

ma route back

router.delete("/deleteTweet/:id", (req, res) => {
  // if (!checkUser(req.params.token)) {
  //   res.json({ results: false, error: "Missing or empty fields" });
  //   return;
  // }
  Tweet.deleteOne({ _id: req.params.id }).then(() =>
    res.json({ result: true })
  );
});
2
  • Does the Tweet.deleteOne function return anything ? Commented May 5, 2024 at 8:44
  • Please add more information to this question. Also, the text "mon code front" does not make any sense to me. Including some figures will be helpful too! Commented May 5, 2024 at 17:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.