0
const loadUsers = async () => {
  const res = await fetch('https://www.breakingbadapi.com/api/characters')
  const json = await res.json()
  return json
}

let chars = loadUsers()

Why does it return a promise ? If i try to add await keyword to load users i get an error? So what s the problem here?

Pointy
  • 405,095
  • 59
  • 585
  • 614
John
  • 19
  • 1

1 Answers1

0

Async functions always return a promise. If the return value of an async function is not explicitly a promise, it will be implicitly wrapped in a promise.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function

Chris Li
  • 2,628
  • 1
  • 8
  • 23