So I know that async/await will not work with map. I am just returning my request and using Promise.all() to execute them. My question is that I have other promises inside and was wondering if the Promise.all() will also execute those inside the map in the correct order.
Here is the code:
const productImageIds = Object.keys(data.webImages)
        for(let i = productImageIds.length; i--;){
            const productId = productImageIds[i]
            const images = data.webImages[productId]
            const requests = images.map(async (image, i) => {
                const name = `${productId}_${i}.${image.split(`.`).pop()}`
                const imageStream = await downloadImage(image, name) // IS THIS WORKING CORRECTLY WITH USING PROMISE.ALL() ??
                const res =  sanityRequest({
                    ...sanityConfig,
                    type: `images`,
                    endpoint: `assets`,
                    contentType: `image/jpeg`,
                    body: imageStream,
                params: `?filename=${name}`,
                })
                    await unlinkSync(name) // IS THIS WORKING CORRECTLY WITH USING PROMISE.ALL() ??
                    return res
            })
            const uploadedImages = await Promise.all(requests)
        }

Promise.allresolves when all Promises end, whatever their order.for(let i = productImageIds.length; i--;){to befor(let i = productImageIds.length-1; i--;){to avoid accessing out of bounds.