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

112
Vistas
I am trying to delete data from database but my codebase is not working

`

import React from 'react';
import useLoadFurnitures from '../../hooks/useLoadFurnitures';

const ManageInventory = ({furniture}) => {
    const { _id, name, img, des, price, quantity, supplier } = furniture;
    const [furnitures, setFurnitures] = useLoadFurnitures(); 
    const handelDelete = (id) => {
        const proceed = window.confirm('Are you sure you want to delete?');
        if (proceed) {
            const url = `http://localhost:5000//furnitures/${id}`;
            console.log(url);
            fetch(url, {
                method: 'DELETE'
            })
                .then(res => res.json())
                .then(data => {
                    console.log(data);
                    alert('Successfully deleted furniture');
                    const restFurniture = furnitures.filter(furniture._id !== id);
                    setFurnitures(restFurniture);
                    
            })
        }
        
    }
    
    return (
        <div className='mb-4'>
            <div className='img-container border p-4 rounded-lg'>
                <img className='w-full' src={img} alt="" />
                <h4 className='text-center  mt-2 text-xl font-bold'>{name}</h4>
                <h4 className='text-center '>{des}</h4>
                <h4 className='text-center font-bold'>Price: $ {price}</h4>
                <h4 className='text-center font-bold'>Quantity: {quantity}</h4>
                <h4 className='text-center font-bold'>Supplier: {supplier}</h4>
                <div className='flex justify-center'>
                <button onClick={()=>handelDelete(furniture._id) } className='bg-[red] px-2 py-1 mt-4 mr-2 text-white font-bold'>Delete</button> 
                </div>
                
            </div>   
        </div>
    );
};

export default ManageInventory;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

`I am trying to delete data both from database and from my UI. I have an error i dont understand how to fixed it . I am using ReactJS for front End and NodeJS for back-end server and MongoBD as a nosql database. What should i do to fixed this error? I am attaching My screenshot to show what is the error is.When i click on the delete button this error occur in the console

about 4 years ago · Juan Pablo Isaza
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