0.0.11 • Published 5 years ago

higher-order-fetch v0.0.11

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

HIGHER-ORDER FETCH

Using window.fetch() with some handful composable logic.

Why you need this

See my article here.

tldr;

This library provides a set of handful fetch enhancement as well as gives you the idea to create a fetch method that:

Installation

npm install higher-order-fetch

or

yarn add higher-order-fetch

How to use

Step 1: Compose your fetch:

// fetchHelper.js
import { defaultHeadersHOF } from "higher-order-fetch/lib/defaultHeaders";
import { onErrorRetryHOF } from "higher-order-fetch/lib/onErrorRetry";
import { myHOF } from "./myHOF";
import pipe from "higher-order-fetch/lib/utils/pipe";

const fetchHelper = {
  fetch: pipe(
    onErrorRetryHOF,
    defaultHeadersHOF,
    myHOF
  )(window.fetch)
};
export default fetchHelper;

Step 2: Use it

// somewhere-that-need-to-fetch-data.js
import fetchHelper from "./path/to/fetchHelper.js";

fetchHelper.fetch("http://my.url/data").then(/* ... */);

Example

Checkout the example for a recommended fetch setup and usage

API

https://rudyhuynh.github.io/higher-order-fetch/identifiers.html

LISCENE

MIT

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago