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

639
Views
Error al eliminar, diciendo: 'Solicitud fallida con código de estado 404', nombre: 'AxiosError', código: 'ERR_BAD_REQUEST'

Actualmente estoy creando un sistema de tienda de suplementos y estoy usando MERN Stack y Axios. No puedo entender por qué la función de eliminación no funciona. Soy nuevo en esto así que por favor echa un vistazo a esto.

PD: El backend del código funciona bien. Lo comprobé con el CARTERO. El problema es con la función onDelete.

back-end

 router.route("/delete/:id").delete(async (req,res) => { let supplementId = req.params.id; await Supplement.findByIdAndDelete(supplementId) .then(() => { res.status(200).send({status: "Supplement Deleted"}) }).catch((err)=>{ console.log(err); res.status(500).send({status: "Error when deleting data", error : err.message}); }); })

Interfaz

Eliminar operación

 const getData = () => { axios.get(`http://localhost:8000/supplement/`) .then((res) => { setSupplements(res.data); }) } const onDelete = (id) => { axios.delete(`/delete/${id}`) .then(() => { alert("Deleted Successfully!") getData(); }) .catch((err) => { alert(err.message); }); }

Botón

 <Button variant="outline-danger" onClick={() => onDelete(supplement._id)}> Delete</Button>
over 4 years ago · Santiago Trujillo
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!