1.3.1 • Published 6 years ago

jhr v1.3.1

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
6 years ago

NPM version Dependency Status

Promise based XHR client with JSON as default.

Installation

npm install --save-dev jhr

Usage

This module attempts to treat AJAX/XHR requests as a function of http. Responses are typed for common http statuses (see the Response submodule) un-supported ones have the type Response.Untyped.

import * as Agent from 'jhr';

let agent = new jhr.Agent();

agent.get('http://example.com').
then((r:jhr.Response)=> {

  if(r instanceof jhr.Response.Ok)
     //it's ok
  else if(r instanceof jhr.Response.Conflict)
    //it's a conflict
  else if(r instanceof jhr.Response.InternalServerError)
    //it's serious
  else
    //it's a regular jhr.Response.Untyped

}).
catch(e=>{

  //TransportError

});

License

Apache-2.0 © Lasana Murray

1.3.1

6 years ago

1.3.0

6 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago