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

157
Views
"mensaje": se muestra "Acceso no autorizado", el método de obtención no funciona

cuando publico este método en mi base de datos MongoDB, funciona correctamente, pero cuando quería obtenerlo, aparece {"mensaje": "Acceso no autorizado"} en mi http://localhost:5000/mi sitio. Lo que quería todo está bien. Pero get no funciona

//código del lado del servidor

 app.post("/my", async (req, res) => { const my = req.body; const result = await myCollection.insertOne(my); res.send(result); }); app.get("/my", async (req, res) => { const query = {}; const cursor = myCollection.find(query); const services = await cursor.toArray(); res.send(services); });

// código del lado del cliente

 const onSubmit = (data, event) => { const url = `http://localhost:5000/service`; fetch(url, { method: "POST", headers: { "content-type": "application/json", }, body: JSON.stringify(data), }) .then((res) => res.json()) .then((result) => { setIsReload(!isReload); if (result) { alert("Add Successful"); } }); const order = { email: user.email, name: event.target.name.value, description: event.target.description.value, price: event.target.price.value, quantity: event.target.quantity.value, }; axios.post(`http://localhost:5000/my`, order).then((res) => { const { data } = res; console.log(data); if (data.insertedId) { alert("Inserted"); } event.target.reset(); console.log(res); }); };
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!