I have two functions as following function 01
export const generateProductList = async (products: IProduct[]) => {
const productList: IProduct[] = [];
products.map((product: IProduct, i: number) =>{
downloadImageAwsS3(product.image)
.then(res => {
productList.push({...product, image: res})
})
})
console.log(productList)
return productList
}
function 02
const productGenerator = (products: IProduct[]) => {
const checkoutList: any[] = [];
generateProductList(products)
.then((res) => {
console.log(res)
res.map(product => {
checkoutList.push(product)
console.log(product)
})
return checkoutList
})
}
in the second function inside .then() and inside the map function is not working properly, Can anyone help me to figureout this