85
etrock
2y

#10YearsChallenge 😂

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

    ;)
  • 3
    @musician I thought it was impossible to use await outside. Also inner await is unnecessary
  • 3
    @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.
  • 3
    @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.
  • 2
    @tmpnull welp here is a juniour.
  • 3
    @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 :/
  • 2
    @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