http-rx
v2.1.9
Published
A reactive http client based on Observable and Request
Downloads
108
Readme
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