Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So we are sending a Get request.
This first HTTP request here,
whenever this button is clicked.
Now I mentioned that we're dealing with promises here,
patch returns a promise,
and that's why we have these Then calls.
And just in case it shouldn't be clear,
promises are nothing react specific.
It's a JavaScript language feature.
Now you might be aware that
when you're dealing with promises,
you can build these Then chains here,
so Then call after Then call,
but you can also use an alternative syntax, async await.
You can add the async keyword in front of the function
and then a weight and operation
which is returning a promise.
And it's just a transformation in your code
which behind the scenes basically does the same
as if you do use these Then blocks.
It's just a bit easier to read
because now you can say,
const responds equals await fetch,
and you can remove this Then block,
and you can then say,
const data equals response.json,
and add await in front of that.
And then get rid of that,
and of that,
and simplify to code to look like this.
Now it's still asynchronous code
as you can tell by the async keyword.
It looks synchronous.
It looks like we execute step after step
but behind the scenes, you can imagine,
that it's still transformed to this syntax
you saw a second ago with these Then calls.
I just use async await here,
because it's a bit easier to read, I would argue.
So that's something we can also do
if we're working with promises here.
Again, this is not react specific,
this is also a default JavaScript feature.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.