Home > OS >  Get image paths uploaded to Cloudinary from NodeJS
Get image paths uploaded to Cloudinary from NodeJS

Time:05-05

I can correctly upload images to Cloudinary by looping through an array as follows:

        const imagesToCloudinary = req.files.map ( data => {
            cloudinary.v2.uploader.upload(data.path)
        });

        let imageResponses = await Promise.all(imagesToCloudinary);

        console.log(imageResponses);

But in console I never get any information which in this case I require the routes.

response in console:

[ undefined, undefined, undefined ]

CodePudding user response:

const imagesToCloudinary = req.files.map ( data => {
   // missing return statement
    return cloudinary.v2.uploader.upload(data.path)
});

let imageResponses = await Promise.all(imagesToCloudinary);

console.log(imageResponses);
  • Related