1.3.1 • Published 7 years ago

jhr v1.3.1

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
7 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

7 years ago

1.3.0

7 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

9 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago