Skip to content

Instantly share code, notes, and snippets.

@SeanPlusPlus
Created February 19, 2017 21:03
Show Gist options
  • Select an option

  • Save SeanPlusPlus/c4434081b68be6dc02eca1d0d0010bdc to your computer and use it in GitHub Desktop.

Select an option

Save SeanPlusPlus/c4434081b68be6dc02eca1d0d0010bdc to your computer and use it in GitHub Desktop.
network request with rxjs
import Rx from 'rxjs';
import axios from 'axios';
const url = 'https://api.github.com/users/SeanPlusPlus'
const requestStream = Rx.Observable.of(url);
const responseStream = requestStream
.flatMap(requestUrl =>
Rx.Observable.fromPromise(axios.get(requestUrl))
);
responseStream.subscribe(response => {
console.log(response.data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment