Im hitting two different endpoints and I am trying to extract the img value which returns a promise, I am trying to obtain the promise result as a string and assign it to the image value in the map function.
This is what I am getting as returned
Here is the code which is returning the promise
async function loadPlacesWithImages() {
const getImage = async (placeId) => {
const request = await fetch("https://byteboard.dev/api/data/img/" + placeId);
const data = await request.json();
return data.img;
};
const getListing = async (api) => {
const request = await fetch(api);
const data = await request.json();
let newArr = data.places.map((element) => ({
id: element.id,
name: element.name,
address: element.address,
stars: element.stars,
reviews: element.reviews,
price: element.price,
description: element.description,
img: getImage(element.id),
}));
console.log(newArr);
};
}
To assign the img value I need it in a string but the promise returns a object as shown in the picture, so how would I get the result of the promise based on my code.