Code Snippets

async function getZen() {
  const res = await fetch('https://api.github.com/zen');
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return res.text();
}

getZen().then(console.log).catch(console.error);