Created
February 5, 2020 23:21
-
-
Save dominikkaegi/0a9f94ac78746056d028e221f7bcce53 to your computer and use it in GitHub Desktop.
How to get the data from a readable stream
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
| // When we fetch data we get a readable stream as a response in the body. | |
| // To receive the data we can call the `json()` function on the response. | |
| // That reads out the full response and returns us a json object instead of a stream object. | |
| fetch('https://api.coindesk.com/v1/bpi/currentprice.json') | |
| .then(res => res.json()) | |
| .then(data => console.log(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment