Reputation: 15481
I am attempting to use RxJS via rx-http-request
to query third party APIs from a NodeJS server. In the long run, I want to use RxJS to handle some of the more interesting error cases. But for the time being I am having issues getting a fairly trivial case to run.
Case 1 (this works):
third_party.js
import {RxHttpRequest} from 'rx-http-request'
export default ((name) => RxHttpRequest.get(`www.third.party.com/${name}`)
And then,
import third from './third_party'
third('bob').subscribe(console.log)
Case 2(this does not)
import third from './third_party'
import Rx from 'rx'
Rx.Observable.forkJoin(third('bob')).subscribe(console.log)
Case 1 prints the (correct) third party response. Case 2 doesn't appear to ever run at all. When I print out console.log(Rx.Observable.forkJoin
) it prints Function
, e.g. I have in fact included the right part of Rx.
Case 3: In thirdParty:
export default ((name) => RxHttpRequest.get(`www.third.party.com/${name}`).map((res)=>console.log(res))
The inner console.log triggers, but the outer subscribe does not. Why is this behaviour happening? And how can I actually send the values into the outer subscribe?
Upvotes: 0
Views: 209
Reputation: 58440
If you are importing rx-http-request
like this:
import { RxHttpRequest } from 'rx-http-request';
You likely installed it like this:
npm install --save rx-http-request
And you might not have noticed this warning message:
npm WARN deprecated [email protected]: This package is no longer maintained and was moved to @akanass/rx-http-request.
That version (1.2.0) is way behind the version that's in the GitHub repo (2.3.0).
Try using @akanass/rx-http-request
, instead:
npm install --save @akanass/rx-http-request
import { RxHR } from '@akanass/rx-http-request';
The export appears to have changed, so you should consult the docs.
Also, you should take some care with rx-http-request
, as it includes rxjs
as a dependency, rather than a peer dependency. This opens the possibility of multiple rxjs
packages being installed (depending upon versions and installation order). I would encourage you to raise an issue to have it changed to a peer dependency.
Upvotes: 1