$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #160

Which fix removes the bug?

async function load() {
  const res = fetch('/api/data');
  return res.json();
}
  1. Await the fetch call
  2. Return the promise
  3. Mark json() as async
  4. Add a catch handler
Without await, res is a Promise and has no json method.
Play Problem Solving ▸