DEV Community

Shashwat Seth
Shashwat Seth

Posted on

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

Top comments (3)

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