This package has been deprecated

Author message:

No longer maintained.

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

1.3.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i jhr

Weekly Downloads

12

Version

1.3.1

License

Apache-2.0

Unpacked Size

102 kB

Total Files

46

Last publish

Collaborators

  • metasansana