OscarDev
OscarDev

Reputation: 977

Get image paths uploaded to Cloudinary from NodeJS

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 ]

Upvotes: 0

Views: 654

Answers (1)

Sathya
Sathya

Reputation: 621

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);

Upvotes: 1

Related Questions