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

110
Views
Status does not change when I delete data from here
const [products, setProducts] = useMangeProduct([]);
const handelDeleteProduct = id => {
        const url = `https://fierce-everglades-14403.herokuapp.com/product/${id}`;
        fetch(url, {
            method: 'DELETE',
        }).then(res => res.json())
            .then(data => {
                console.log(data);
                if (data?.acknowledged === true) {
                    const restProducts = products.filter(product => product._id !== id)
                    setProducts(restProducts);
                    toast.error('Product Delete successfully')
                }
            })
    }

** state Change** data deleted but state not change. if I reload the page so I can see my data is deleted. But when I click on the delete button, there is no change.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You mean that way?

let sure = confirm('Do you want to delete your constumer?');
if (sure) {
    // code to send fetch to your server
}
about 4 years ago · Juan Pablo Isaza Report

0

I have used something like this for Anchor Link. Hope that helps.

<a href="#" onclick="if (confirm('Do you really want to delete this User?')) {return true;}else{event.stopPropagation(); event.preventDefault();};"> Delete User </a>
about 4 years ago · Juan Pablo Isaza Report
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!