Mongodb webhook gives 404, but not with fetch

Hello everyone, I am trying to reverse engineer and build my own application off of this course here on FCC.

The only problem I am running into is I have my own mongodb collection, and I am trying to connect with it the same way that the teacher does.

//http common file 
export default axios.create({
  baseURL:("https://us-west-2.aws.webhooks.mongodb-realm.com/api/client/v2.0/app/my_pets-dbdsd/service/pets/incoming_webhook/petswebhook"),
   
  headers: {
    "Content-type": "application/json"
  }
});

my petList.js file

const getPetInfo = () => {
  getPetInfoService.getAll()
    .then(response => {
      console.log(response.data);
      setPets(response.data.restaurants);
      
    })
    .catch(e => {
      console.log(e);
    });
};

this is giving me a 404 error, and I’m not sure why. Interestingly enough why I fetch the data from the url, it will return the data no problem. And I would just use that if I knew how to use this method to do all of the other api calls.

//This one works just fine 
  async function getPetInfo() {
    const response = await fetch('https://us-west-2.aws.webhooks.mongodb-realm.com/api/client/v2.0/app/my_pets-dbdsd/service/pets/incoming_webhook/petswebhook');
    const json = await response.json();
    console.log(json); 
     setPets(json.pets);
     console.log('this is pets')
     console.log(pets) 
}

If anyone could help me out with this. I’d very much appreciate it.
Thank you in advance.

I forgot to add, my code is here: GitHub - Imstupidpleasehelp/MERN-lesson
And the source lesson code is here: GitHub - beaucarnes/restaurant-reviews

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.