Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Treora/response-to-data-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

response-to-data-url

Tiny javascript module that, given a Response object (returned by e.g. fetch()), returns (a Promise of) the response body as a data: URL.

Install

npm install response-to-data-url

Use

Example case, fetching some resources:

import responseToDataUrl from 'response-to-data-url'

fetch('https://example.com/pic.png')
  .then(responseToDataUrl)
  .then(dataUrl => {
    // dataUrl === 'data:image/png;base64,somelongstringofdatahere'
  })

API

responseToDataUrl(response)

Arguments:

Returns a Promise that resolves with a string.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published