DEV Community

loading...

Discussion on: Have a Handy JS Snippet You Want to Share?

Collapse
aravindballa profile image
Aravind Balla

Let me break that up.

const response = await fetch('https://api.github.com/users/wesbos');

const data = await response.json(); //this gives us the JSON data from the response.
Enter fullscreen mode Exit fullscreen mode

Previously it used to be,

fetch('https://api.github.com/users/wesbos')
.then(res => res.json()) //json() also returns a promise
.then(data => {console.log(data)});

Enter fullscreen mode Exit fullscreen mode
Thread Thread
coding_with_ju profile image
coding_with_ju

Ahhh I see, that's amazing thanks for that! <3

Thread Thread
wesbos profile image
Wes Bos

Thanks! I just clarified this in a tweet:

twitter.com/wesbos/status/95583181...

Thread Thread
coding_with_ju profile image
coding_with_ju

Thanks Wes, keep up the good work! Loving them tasty treats :P