Re:Removing jQuery from GitHub.com frontend
by Ajedi32 on Wednesday July 25, 2018 @09:42PM
(#17614490)
For comparison, here's the first example, but using fetch:
And as an added bonus, fetch uses promises, so in an async function that's just:
[ Parent
| on HN ]
Re:Removing jQuery from GitHub.com frontend
by Cthulhu_ on Thursday July 26, 2018 @05:41AM
(#17616201)
I'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).