I'm new to Promises and currently I have an object that looks like this:
Animals{food:{...}, recreation:{...}, toys:{...}}
Currently to access the attributes I'm running Animals.food, Animals.recreation ect. We recently want to change this to an async call and the recommendation was to use a Promise. So I did the following:
function getAnimalFood(){
return Promise.resolve(this.food)
}
function getFood(id){
const allFood = this.getAnimalFood();
return allFood[id];
}
My question is how do I access the actual promise object from food
that has the data?