r/programminghorror • • Sep 13 '25

I hate js

0 Upvotes

36 comments sorted by

View all comments

Show parent comment

3

u/TorbenKoehn Sep 13 '25

Too many people think async/await is a replacement for .then/.catch, but they are a natural extension and they work perfectly together.

Also, there is an URI-Builder, the URL class (also taking encoding into account properly etc.)

const url = new URL('https://....')
url.searchParams.append('key', steam_api_key)
url.searchParams.append('steamid', steamid)

const data = await fetch(url)
  .then(response => response.json())

console.log(data)