Created
January 20, 2023 11:54
-
-
Save krzysztofMlczk/2bcb39e777aa6cb5e4730d15d593f205 to your computer and use it in GitHub Desktop.
Get mime type from image URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getMimeTypeFromImageUrl(imageUrl: string) { | |
try { | |
const response = await fetch(imageUrl, { method: 'HEAD' }); | |
return response.headers.get('content-type'); | |
} catch (err) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment