Skip to content

Instantly share code, notes, and snippets.

@jjylik
Created March 28, 2021 07:07
Show Gist options
  • Save jjylik/3a96305cc9749b15870b545a020f9f58 to your computer and use it in GitHub Desktop.
Save jjylik/3a96305cc9749b15870b545a020f9f58 to your computer and use it in GitHub Desktop.
Fetch content length
async function fetchContentLength(url: string): Promise<string | null> {
const response = await fetch(url, {method: 'HEAD'});
return response.headers.get('content-length');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment