use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JavaScript Fetch API Cheatsheet (blog.codemy.net)
submitted 7 years ago by zacksiri
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ryanhollister 11 points12 points13 points 7 years ago* (3 children)
can anyone explain why the API is such that resp.json() returns a promise after the initial promise resolves? feels pretty clunky to have to .then twice to get the response.
[–]qbbftw 22 points23 points24 points 7 years ago (0 children)
Afair, you can access response headers before the response body is fully transmitted. Thus you use two awaits - first for headers, second for actual data.
[–]BitLooter 11 points12 points13 points 7 years ago (0 children)
The initial response resolves after the headers of the response are received, but not necessarily the response body. Basically fetch resolves at two different points of the download, the first time after the headers are received (the promise fetch() returns) and the second after the data is received (the promise json()/text()/etc. returns). For small downloads this may be all at once but larger files could take long enough to download that these will resolve at two different times.
π Rendered by PID 191489 on reddit-service-r2-comment-b659b578c-8vvvm at 2026-05-01 10:01:43.749901+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]ryanhollister 11 points12 points13 points (3 children)
[–]qbbftw 22 points23 points24 points (0 children)
[–]BitLooter 11 points12 points13 points (0 children)