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

159
Views
"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
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!