universal-rxjs-ajax
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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

Package Sidebar

Install

npm i universal-rxjs-ajax

Weekly Downloads

1,183

Version

3.0.0

License

MIT

Unpacked Size

11.9 kB

Total Files

22

Last publish

Collaborators

  • mcmunder