Cheks if a given URL for an image is available over the net. It uses a simple DOM trick to test it. Be careful as <img src>
can be an XSS attack vector: https://owasp.org/www-community/xss-filter-evasion-cheatsheet
npm i -S gist:b2efa76be5314a332cfcfd1d025f4601
import { imageExists } from 'img-exists'
const src = "https://..."
imageExists(src)
.then(({ img }) => {
document.body.appendChild(img) // or whatever
})
.catch(({ error }) => console.log(error))