1.0.7 • Published 4 years ago

multiple-fetch v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

multiple-fetch

npm bundle size npm npm type definitions npm

Make multiple fetch requests and structurize responses.

Installation

# pnpm / npm
pnpm i multiple-fetch isomorhpic-unfetch
# yarn
yarn add multiple-fetch isomorhpic-unfetch

Example

import 'isomorhpic-unfetch'
import multiFetch from 'multifetch'

const urls = ['todos', 'comments']

const results = await multiFetch(
  urls,
  {
    method: 'GET',
    headers: {
      token: 'lol'
    }
  },
  { parse: 'json', domain: 'https://jsonplaceholder.typicode.com/' }
)

console.log(results)

/*

{
  "results": {
    "todos": [...]
  },
  "errors: [{
    "response": {
      status: 404,
      ...
    }
    "url: "https://jsonplaceholder.typicode.com/comments"
  }],
  "serverErrors": []
}

*/
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago