Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
"message": "Unauthorized Access" is showing, get method is not working

when I post this method in my MongoDB database it's working properly, but when I wanted to get it it's showing {"message": "Unauthorized Access"} in my http://localhost:5000/my site. The thing which I wanted everything is ok. But get is not working

//server side code

 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);
      });

//client side code

 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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda