im trying to fetch an image through url in nodejs ( using node-fetch ), something like this
fetch(url)
.then(async res => {
const dest = fs.createWriteStream(filename);
res.body.pipe(dest)
})
.catch((err) => {
console.log(err)
})
the thing is i dont know how to check if the image is loaded properly with this method or not and of course the image will be broken like this
Any suggestion guys? Thanks for reading