Skip to content

Instantly share code, notes, and snippets.

@dominikkaegi
Created February 5, 2020 23:21
Show Gist options
  • Select an option

  • Save dominikkaegi/0a9f94ac78746056d028e221f7bcce53 to your computer and use it in GitHub Desktop.

Select an option

Save dominikkaegi/0a9f94ac78746056d028e221f7bcce53 to your computer and use it in GitHub Desktop.
How to get the data from a readable stream
// 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