DEV Community

How do I display multiple image urls that are saved in mongodb with same username on the web in react

Shashwat Seth on October 29, 2020

Collapse
 
zdev1official profile image
ZDev1Official

That's if you are using mongoose

const images = await Image.find().sort({date: 'desc'})
images.forEach(image => {
    console.log(image.url);
});
Enter fullscreen mode Exit fullscreen mode
Collapse
 
shashwatseth profile image
Shashwat Seth

Each image urls are in different documents. Will the above code works

Collapse
 
zdev1official profile image
ZDev1Official

Yes that's right