Skip to content

Reactive http client based on Observable and Request

License

Notifications You must be signed in to change notification settings

JasonRammoray/HttpRx

Repository files navigation

Travis build Maintainability Test Coverage npm statistic

HttpRx

A JavaScript library wrapping best of Observable and Request. No more, no less.

It does only one thing and does it very well - provides a possibility to execute http requests in reactive manner.

It does not break http semantics.

See live demo HERE.

This means, that everything with status code less than 400 is considered to be a success and everything with status code more or equal to 400 is considered to be an error.

Examples

const httpRx = require('http-rx');
const { map, catchError, finalize } = require('rxjs/operators');
const userName = 'jasonrammoray';
const url = `https://api.github.com/users/${userName}`;
httpRx.get(url, {
    headers: {
      'User-Agent': 'Test user Agent'
    },
    json: true
})
.pipe(
    map(data => data.body.bio),
    catchError(error => console.error('Can not obtain user data, because: ', error)),
    finalize(() => console.info('GitHub user data fetching procedure is done'))
)
.subscribe(userBio => console.log(`GitHub user bio is: ${userBio}`));

Pull-requests

Rules are simple:

  • cover your changes with tests
  • make sure, that your code complies with coding standards in the project

About

Reactive http client based on Observable and Request

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •