Categories
JavaScript Answers

How to get a file or blob from an object URL with JavaScript?

Spread the love

To get a file or blob from an object URL with JavaScript, we use fetch.

For instance, we write

const r = await fetch(url);
const blob = await r.blob();

to call fetch with the object url to get the r response from the returned promise via await.

Then we call r.blob to return a promise with the blob.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *