Q:

Saving images to localStorage using fetch() and blob()

Unfortunately there aren't any working examples of a code mentioned in the title.
All found around were either a bit old-fashioned like canvas or too long.
fetch('https://www.stevensegallery.com/320/240')
  .then(pic => pic.blob())
  .then(pic => localStorage['pic'] = pic);

Is there any concise one-liner to do it without writing a separate function?

A:

Finally made it not too heavy. Also had to JSON.parse it before putting into actual source.

fetch('https://source.unsplash.com/300x170/?girl')
  .then(pic => pic.blob())
  .then(pic => {
    const fr = new FileReader();
    fr.onload = () => { 
      const dataURL = fr.result;
      document.getElementById('pic').src = dataURL;
      localStorage['pic'] = JSON.stringify(dataURL);
    }
  fr.readAsDataURL(pic);
});
<img id='pic' />

