Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
I wanna delete a post from my UI but I have a problem

I want to delete a post from my UI. I already did app.delete in my server site. I use MongoDB and nodejs for the server.

const ManageItem = () => {
    const navigate = useNavigate();
    const [items, setItems] = useItems();


    const handleToNavigate = () => {
        navigate('/additem')
    }

    const handleDelete = id => {
        const proceed = window.confirm('Are you sure you want to delete?');
        if (proceed) {
            const url = `http://localhost:5000/item/${id}`;
            fetch(url, {
                method: 'DELETE'
            })
                .then(res => res.json())
                .then(data => {
                    console.log(data);
                    const remaining = items.filter(item => item._id !== id);
                    setItems(remaining);

                })
        }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your question is very unclear. For now I can only assume that you are filtering out the deleted data and setting the rest of the data in a state. Either you are not loading the state in the ui properly or there is something wrong in your server side. Please provide your code for better understanding. Till then try this out in your server side, if you haven't already.

app.delete("/item/:id", async (req, res) => {
      const id = req.params.id;
      const query = { _id: ObjectId(id) };
      const result = await databaseCollection.deleteOne(query);
      res.send(result);
    });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda