83
etrock
6y

#10YearsChallenge 😂

Comments
  • 22
    At least there was some form of error handling 10/20 years ago 👅
  • 3
    Node or browser?
  • 5
    Beautiful indeed
  • 5
    const data = await (await fetch(url)).json()

    ;)
  • 2
    @musician I thought it was impossible to use await outside. Also inner await is unnecessary
  • 2
    @melezorus34 it needs to be inside an async function. But hows the inner await useless? Try it out in the browser.
  • 5
    I still teach this method to teenagers when doing JavaScript for the first time.
  • 2
    @musician I mean, if you use it inside the paranthesis, it will wait the inside statement to complete. Then the parantheses get the value and you wait the value again. You lose a tick at there. It is longer than you can think actually.
  • 1
    @tmpnull welp here is a juniour.
  • 2
    @melezorus34 maybe i misunderstand you but you need 2 await since fetch returns a promise
    One for the fetch and one for the .json()
  • 3
    Old version is more readable :/
  • 1
    @njedwards There's still a form of error handling
  • 1
    Anyone who has written JavaScript industrially and thinks the left side is more readable/better is very mistaken...
Add Comment