1.0.2-beta.2 • Published 4 years ago

abortable-networking v1.0.2-beta.2

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

abortable-networking

Provides an abortable implementation for superagent. Optimised for working with JSON & typescript, but all of the functions provided work with the superagent request object, so any of the functionality in super agent can still be used.

Installation

yarn add abortable-networking

or if you prefer npm

npm install abortable-networking --save

Usage

import { AbortableRequest, fetchJson, from } from 'abortable-networking

const fromZoo = from('https://zoo.example.com');

type CutestResponse = { animal: string };
const fetchCutestAnimal = (): AbortableRequest<CutestResponse> =>
  fetchJson(fromZoo('/cutest-animal'))
  
type NewAnimalRequest = { name: string, cutenessRating: number };
type NewAnimalResponse = { id: number };
const addNewAnimal = (animal: NewAnimalRequest): AbortableRequest<AnimalResponse> =>
  fetchJson(
    withJsonBody(animal)(
      fromZoo('/animals', 'post')));
1.0.2-beta.2

4 years ago

1.0.0-beta.0

5 years ago

0.8.0

5 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.7

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.0

7 years ago