
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
RxJS-flavored version of HTTP fetch API for node.js.
IMPORTANT: This library only supports RxJS 4.x.
Looking for RxJS 5.0+ support? Try rxjs-fetch. (Same name but replace 'rx' with 'rxjs'.)
Built on top of isomorphic-fetch.
fetch as a global so that its API is consistent between client and server.npm install --save rx-fetch
const rxFetch = require('rx-fetch');
rxFetch('http://tangledfruit.com/mumble.txt')
.subscribe(
response => {
/*
Occurs exactly once. "response" is an Object with the following properties:
- status (Number): HTTP status code
- ok (Boolean): true if status < 400
- statusText (String): HTTP status string
- headers (Object): Maps HTTP headers in the response to string values
- url (String): URL that was requested.
"response" has the following methods:
- text: Returns another Observable which resolves with the response body
as a String when available.
- json: Returns another Observable which resolves with the response body
parsed as JSON (i.e. an Object or Array) when available.
It is an error to call more than one of these methods or to call any
of these methods more than once.
*/
},
err => {
console.log(err);
// Should only happen if unable to reach server.
// Server error responses (status code >= 400)
// are not automatically mapped to errors.
});
There are some shortcut methods available on the Observable object that is returned from rxFetch:
rxFetch('http://tangledfruit.com/mumble.txt').failOnHttpError()
// -> This Observable will yield an onError notification using the HttpError
// object described below if the HTTP status code is >= 400.
rxFetch('http://tangledfruit.com/mumble.txt').failIfStatusNotIn([200, 404])
// -> This Observable will yield an onError notification using the HttpError
// object described below if the HTTP status code is anything other than the
// codes listed (in this case, 200 and 404).
rxFetch('http://tangledfruit.com/mumble.txt').text()
// -> This Observable will yield an onNext notification containing only the
// body text of the HTTP response. The HTTP headers and status are discarded.
// This call implies .failOnHttpError().
rxFetch('http://tangledfruit.com/mumble.txt').json()
// -> This Observable will yield an onNext notification containing only the
// body of the HTTP response parsed as JSON. The HTTP headers and status are
// discarded. This call implies .failOnHttpError().
const recording = new Rx.ReplaySubject(); // can be any Subject
rxFetch('http://tangledfruit.com/mumble.txt').recordTo(recording).json()
// -> Same as above, but it will capture the request and response and
// send it to the Subject in a syntax that can then be used to write unit
// tests using Nock. (See rx-fetch's own unit tests for an example.)
// You can also invoke this by adding recordTo: subject in the options
// object on the .get method.
The .failOnHttpError and .failIfStatusNotIn methods will send an onError
notification with an HttpError object. This is the standard Error Object,
but it has an extra member response from which you can access other properties
as described earlier.
The message for the error will be "HTTP Error (status code): (server message)". For example, "HTTP Error 404: Not Found".
MIT
FAQs
RxJS-flavored version of HTTP fetch API for node.js
We found that rx-fetch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.