0.1.0 • Published 7 years ago

response-to-data-url v0.1.0

Weekly downloads
7
License
Unlicense
Repository
github
Last release
7 years ago

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.