'Get async results within .map function

I'm trying to get photos in map function from Nest.js server. This is slider component. I give an array of slides as input and show on within a map. The thing is, I need to get real file from server (by res.sendFile..) while doing .map.

I searched and tried a few variants, this is the last, but still get errors.

what do I do wrong? Please, help

const Slider = async ({videos}) => {

   async function getImageHandler(fileName) {
        return getImageFromNestServer(fileName).then(async (response) => {
            const fileType = await FileType.fromBuffer(response.data);
           
            return `data:${fileType.mime};base64, ${ArrayBufferConverter.encode(response.data)}`;
        })
    }

    let realImg = await Promise.all(
        videos.map(async video => {
                
                try {
                    video.fetchItem = await getImageHandler(video.content_preview_photo.filename)

                    return video;
                } catch(err) {
                    throw err;
                }
            }
        )
    )

return (<MySlide>...</MySlide>)
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source