Skip to content

Instantly share code, notes, and snippets.

@etienne-dldc
Created February 24, 2020 18:08
Show Gist options
  • Save etienne-dldc/ec09393e53c36985b8c17cb113f98bf5 to your computer and use it in GitHub Desktop.
Save etienne-dldc/ec09393e53c36985b8c17cb113f98bf5 to your computer and use it in GitHub Desktop.
async function fetchAsObjectURL(url) {
const response = await fetch(url);
const blob = await response.blob();
return URL.createObjectURL(blob);
}
fetchAsObjectURL('https://jsonplaceholder.typicode.com/todos/1');
function *fetchAsObjectURL(url) {
const response = yield fetch(url);
const blob = yield response.blob();
return URL.createObjectURL(blob);
}
runAsync(fetchAsObjectURL('https://jsonplaceholder.typicode.com/todos/1'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment