I have the following code:
const getNFTs = async (address: string) => {
... // hidden for brevity
//Nested code
const promises = Array.from({length: output.toNumber()}).map() => {
... // hidden for brevity
}
const promiseArray = await Promise.all(promises); //returns object
const imageArray = Object.values(promiseArray); //converts to array
}
If I was to console.log imageArray I am given an array like this:
['https://imagepath.com/image1.png','https://imagepath.com/image2.png','https://imagepath.com/image3.png',]
I want to use imageArray to map through the array and render a grid of images on the UI. But when I try to map through this, I get an error that imageArray is not defined most likely due to scoping issues.
Do I write the map function (with the required HTML/JSX markup) within the getNFTs async function? Or is there a better way to access the array to generate the list of images on the UI?