I need to download images from the array of links to them like this https://miro.medium.com/max/1200/0*UEtwA2ask7vQYW06.png
And there is the code I wrote. I used https://www.npmjs.com/package/image-downloader
const download = require('image-downloader');
const links = require('./links.json');
var options = {
url: "",
dest: links.dest,
};
links.url.forEach((link) => {
options.url = link
download
.image(options)
.then((result) => {
console.log("Image downloaded", result);
})
.catch((error) => console.log("downloaded error", error));
});
And the .json file
{
"url":[
"https://miro.medium.com/max/1200/0*UEtwA2ask7vQYW06.png",
"https://api.time.com/wp-content/uploads/2019/08/better-smartphone-photos.jpg",
"https://iso.500px.com/wp-content/uploads/2016/03/stock-photo-142984111.jpg",
]
"dest":"D:/"
}
But because it works async, all the downloaded images are unordered, not like in the list of links (it can`t be sorted by the date). How can I modify this code to make it download images in ordered way?