DEV Community

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

Collapse
 
aravindballa profile image
Aravind Balla • Edited

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
 
juliani profile image
Julian Iaquinandi

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
 
juliani profile image
Julian Iaquinandi

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