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.