Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda