I am fetching data from an API to get the number of likes. this is the function to get all the data
`
const getLikes = async () => {
const response = await fetch(`https://us-central1-involvement-api.cloudfunctions.net/capstoneApi/apps/${apiKey}/likes`)
const likeData = await response.json();
return likeData;
}
`then I want to store info in a variable so I wrote this other function
`
const likesObj = async ()=> {
const getLike = await getLikes()
return getLike;
}
`
when I console.log the const getLike it does print an Array of objects with every item and the number of likes it has. but when I return getLikes it returns a promise, how can I return the result and not the promise
I tried with .then() but I get the same result
Via Active questions tagged javascript - Stack Overflow https://ift.tt/iKLH3bx
Comments
Post a Comment