4 ms·
To be fair, that site doesn't use `fetch` on the ES side which bloats all the starting examples. Further, there are many better animation libraries. And final
by nwienert 8y ago
To be fair, that site doesn't use `fetch` on the ES side which bloats all the starting examples.
Further, there are many better animation libraries.
And finally if you use any view framework you have very little need to be traversing the DOM.
- floatboth 8y agoThere's also the native Web Animations API!
- Ajedi32 8y agoFor comparison, here's the first example, but using fetch: fetch('/my/url').then((r) => r.json()).then((data) => { }) And as an added bonus, fetch uses promises, so in an async function that's just: let data = await fetch('/my/url').then((r) => r.json())
- aloisdg 8y agoYou can write `(r)` like this `r`. Remove clutter. You don't write `let i = (0)`
- klodolph 8y agoThat’s not a good analogy at all, the () is there in arrow functions always except, as a special case, it’s optional if there’s a single argument.
- Cthulhu_ 8y agoI'm not a fan of mixing await and .then myself; let data = await (await fetch('/my/url')).json(); That's a one-liner, but you can split the request and json data as well (and you usually want to anyway because of error handling).