abortable-networking
TypeScript icon, indicating that this package has built-in type declarations

1.0.2-beta.2 • Public • Published

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')));

Readme

Keywords

none

Package Sidebar

Install

npm i abortable-networking

Weekly Downloads

1

Version

1.0.2-beta.2

License

MIT

Unpacked Size

7.08 kB

Total Files

9

Last publish

Collaborators

  • dean177