fetch-multiple

1.2.3 • Public • Published

fetch-multiple

A tiny library created for fetching multiple assets in one promise.

Here are some basic instructions to get up and running

$ npm install fetch-multiple --save-dev
import fetchMultiple from 'fetch-multiple';
 
const fetchables = {
  '/data.json': 'json',
  '/text.txt': 'text'
};
 
fetchMultiple(fetchables)
  .then(data => {
    console.log(data);
  });
 
  // This function logs:
  // {
  //   '/data.json': { jsonResponse },
  //   '/text.txt': 'textResponse'
  // }

The only argument that the function requires is an object of URLs as keys and values of the desired parsing method.

Available parsing methods are based on what the fetch protocol is capable of:

- arrayBuffer
- blob
- formData
- json
- text

Please note that this library's data structure may change as new features are added in newer releases.

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i fetch-multiple

    Weekly Downloads

    238

    Version

    1.2.3

    License

    ISC

    Unpacked Size

    2.74 kB

    Total Files

    4

    Last publish

    Collaborators

    • seancrater