Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!