Created
February 19, 2017 21:03
-
-
Save SeanPlusPlus/c4434081b68be6dc02eca1d0d0010bdc to your computer and use it in GitHub Desktop.
network request with rxjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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