async promises in a sync way?

This blog post title is pretty confusing - but if you get to read this blog post by Google, it actually makes sense.

It's actually pretty cool. Not that I don't like callbacks or promises, but I can see this being useful in more complex examples.

async function fetchDogPics(url) {
  try {
    //this looks synchronous but it isn't...
    const response = await fetch(url);
    await response.text();

  } catch (err) {
    console.log('failed', err);

  }
}



Comments

Popular posts from this blog

Just learned about rsync

angular.js modules?

Cut/Copy and paste in vi