All language subtitles for 005 Using async _ await_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,210 --> 00:00:05,360 So we are sending a Get request. 2 00:00:05,360 --> 00:00:08,109 This first HTTP request here, 3 00:00:08,109 --> 00:00:10,690 whenever this button is clicked. 4 00:00:10,690 --> 00:00:14,580 Now I mentioned that we're dealing with promises here, 5 00:00:14,580 --> 00:00:16,110 patch returns a promise, 6 00:00:16,110 --> 00:00:18,920 and that's why we have these Then calls. 7 00:00:18,920 --> 00:00:21,240 And just in case it shouldn't be clear, 8 00:00:21,240 --> 00:00:23,890 promises are nothing react specific. 9 00:00:23,890 --> 00:00:26,810 It's a JavaScript language feature. 10 00:00:26,810 --> 00:00:28,480 Now you might be aware that 11 00:00:28,480 --> 00:00:30,950 when you're dealing with promises, 12 00:00:30,950 --> 00:00:34,240 you can build these Then chains here, 13 00:00:34,240 --> 00:00:37,010 so Then call after Then call, 14 00:00:37,010 --> 00:00:41,500 but you can also use an alternative syntax, async await. 15 00:00:41,500 --> 00:00:46,500 You can add the async keyword in front of the function 16 00:00:46,950 --> 00:00:49,660 and then a weight and operation 17 00:00:49,660 --> 00:00:51,900 which is returning a promise. 18 00:00:51,900 --> 00:00:54,800 And it's just a transformation in your code 19 00:00:54,800 --> 00:00:57,190 which behind the scenes basically does the same 20 00:00:57,190 --> 00:01:00,030 as if you do use these Then blocks. 21 00:01:00,030 --> 00:01:02,040 It's just a bit easier to read 22 00:01:02,040 --> 00:01:03,960 because now you can say, 23 00:01:03,960 --> 00:01:07,830 const responds equals await fetch, 24 00:01:07,830 --> 00:01:10,770 and you can remove this Then block, 25 00:01:10,770 --> 00:01:12,210 and you can then say, 26 00:01:12,210 --> 00:01:16,010 const data equals response.json, 27 00:01:16,010 --> 00:01:18,820 and add await in front of that. 28 00:01:18,820 --> 00:01:21,010 And then get rid of that, 29 00:01:21,010 --> 00:01:23,030 and of that, 30 00:01:23,030 --> 00:01:26,040 and simplify to code to look like this. 31 00:01:26,040 --> 00:01:28,880 Now it's still asynchronous code 32 00:01:28,880 --> 00:01:31,200 as you can tell by the async keyword. 33 00:01:31,200 --> 00:01:32,980 It looks synchronous. 34 00:01:32,980 --> 00:01:35,690 It looks like we execute step after step 35 00:01:35,690 --> 00:01:37,790 but behind the scenes, you can imagine, 36 00:01:37,790 --> 00:01:40,910 that it's still transformed to this syntax 37 00:01:40,910 --> 00:01:44,550 you saw a second ago with these Then calls. 38 00:01:44,550 --> 00:01:46,350 I just use async await here, 39 00:01:46,350 --> 00:01:48,800 because it's a bit easier to read, I would argue. 40 00:01:49,790 --> 00:01:51,460 So that's something we can also do 41 00:01:51,460 --> 00:01:53,730 if we're working with promises here. 42 00:01:53,730 --> 00:01:56,310 Again, this is not react specific, 43 00:01:56,310 --> 00:01:59,493 this is also a default JavaScript feature. 3171

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.