Makes rxjs's ajax available in Node.js


Keywords
rxjs, observable, ajax, universal, isomorphic
License
MIT
Install
npm install universal-rxjs-ajax@1.0.4

Documentation

universal-rxjs-ajax

Build Status npm version Join the chat at https://gitter.im/mcmunder/universal-rxjs-ajax

All credit goes to jayphelps. Copied from his suggestion made here.

universal-rxjs-ajax makes Observable.ajax available in Node.js by throwing in xhr2 when necessary.

Usage

const {map} = require('rxjs/operators')
const {request} = require('universal-rxjs-ajax')

interface Repo {
  name: string
}

// config as accepted by Observable.ajax()
const config = {
  url: 'https://api.github.com/orgs/Reactive-Extensions/repos',
  method: 'GET', // and so on...
}

request<Repo[]>(config)
  .pipe(map(({response}) => response.map((repo) => repo.name)))
  .subscribe((repoNames) => console.log(repoNames))

Try it yourself

https://runkit.com/mcmunder/universal-rxjs-ajax-playground

Copyright and license

Copyright 2018, Matthias Munder.
Licensed under the MIT license.

js-standard-style