DEV Community

Discussion on: Beginners Guide To Fetching Data With (AJAX, Fetch API & Async/Await)

 
pierrejoubert73 profile image
Pierre Joubert • Edited

I just did this and it seemed to work:

var foo = null;
fetch('https://jsonplaceholder.typicode.com/posts/1')
   .then(resp => resp.json())
   .then(obj => foo = obj)

Then foo is accessible object like: foo.title
"sunt aut facere repellat provident occaecati excepturi optio reprehenderit"

Thread Thread
 
itachiuchiha profile image
Itachi Uchiha

Thanks a lot. That's exactly what I want.