Skip to content

Instantly share code, notes, and snippets.

@zhouzi
Created August 13, 2019 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhouzi/ccdd390a8edcbffc3b57ecef0787b9e9 to your computer and use it in GitHub Desktop.
Save zhouzi/ccdd390a8edcbffc3b57ecef0787b9e9 to your computer and use it in GitHub Desktop.
(async () => {
const response = await fetch('<url>', {
method: 'get',
headers: {
'Authorization': 'Bearer <token>'
}
});
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = '<filename>';
link.href = url;
link.click();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment