All language subtitles for 021 _getServerSideProps_ and its Context_Downloadly.ir_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,160 --> 00:00:05,460 So, which implications does getServerSideProps 2 00:00:05,460 --> 00:00:09,090 running on the server only have for us? 3 00:00:09,090 --> 00:00:13,150 The implications can be found in this context object 4 00:00:13,150 --> 00:00:16,730 unlike context in getStaticProps 5 00:00:16,730 --> 00:00:19,400 we don't just have access to the params 6 00:00:19,400 --> 00:00:22,950 and a couple of other less important fields 7 00:00:22,950 --> 00:00:27,480 instead, we get access to the full request object as well. 8 00:00:27,480 --> 00:00:30,310 And also to the response which will be sent back 9 00:00:30,310 --> 00:00:32,670 so that we could even manipulate this 10 00:00:32,670 --> 00:00:36,270 and add extra headers if you wanted to. 11 00:00:36,270 --> 00:00:40,290 To be precise we do get a couple of values 12 00:00:40,290 --> 00:00:42,880 a couple of keys in this context object 13 00:00:42,880 --> 00:00:46,010 and we do get access still to the params 14 00:00:46,010 --> 00:00:49,940 that does not change if we have this on a dynamic page 15 00:00:49,940 --> 00:00:51,240 which we don't have here 16 00:00:51,240 --> 00:00:53,580 but if this would be on a dynamic page 17 00:00:53,580 --> 00:00:56,350 we still would get access to params 18 00:00:56,350 --> 00:00:59,880 but in addition, as mentioned, we also get access 19 00:00:59,880 --> 00:01:02,823 to the request object and the response object. 20 00:01:03,670 --> 00:01:06,370 Now, if you know a bit of Node.js 21 00:01:06,370 --> 00:01:08,830 and especially of Express.js 22 00:01:08,830 --> 00:01:10,710 this might look familiar to you. 23 00:01:10,710 --> 00:01:13,170 There you also can write server side code 24 00:01:13,170 --> 00:01:16,450 where you get a request object and the response object 25 00:01:16,450 --> 00:01:18,720 and you can then manipulate the response object 26 00:01:18,720 --> 00:01:21,813 as needed to send back an appropriate response. 27 00:01:22,800 --> 00:01:23,880 Now, you don't need to worry 28 00:01:23,880 --> 00:01:25,960 about sending back a response here 29 00:01:25,960 --> 00:01:28,050 Next.js will do that for you 30 00:01:28,050 --> 00:01:30,120 it will be derendered component 31 00:01:30,120 --> 00:01:32,170 but you can manipulate the response 32 00:01:32,170 --> 00:01:36,280 before it's sent back by adding extra headers, for example 33 00:01:36,280 --> 00:01:39,050 by adding a cookie, for example. 34 00:01:39,050 --> 00:01:42,150 In addition, you can also dive into the request object 35 00:01:42,150 --> 00:01:44,250 that reached the server 36 00:01:44,250 --> 00:01:47,240 and you can read incoming data from there. 37 00:01:47,240 --> 00:01:50,400 For example, headers that were attached through request 38 00:01:50,400 --> 00:01:54,280 and therefore cookie data that was attached to the request. 39 00:01:54,280 --> 00:01:56,830 Request and response the objects we're getting here 40 00:01:56,830 --> 00:02:01,490 are your official Node.js default incoming message 41 00:02:01,490 --> 00:02:03,870 and response objects. 42 00:02:03,870 --> 00:02:07,620 So, here I will briefly lock the request 43 00:02:07,620 --> 00:02:10,600 and then also lock the response 44 00:02:10,600 --> 00:02:14,380 so that we can get a closer look at them. 45 00:02:14,380 --> 00:02:19,380 If I save this and I reload user profile 46 00:02:19,760 --> 00:02:24,040 now this code executed again and now we see a long log here 47 00:02:24,040 --> 00:02:26,410 because these are quite complex objects 48 00:02:26,410 --> 00:02:30,400 with a lot of built in methods and properties. 49 00:02:30,400 --> 00:02:32,070 So, you'll see there's a lot in there 50 00:02:32,070 --> 00:02:35,360 and you definitely don't need to go through all of that. 51 00:02:35,360 --> 00:02:38,820 But for example, you see that there are headers in there 52 00:02:38,820 --> 00:02:41,183 which we could extract if we wanted to. 53 00:02:42,680 --> 00:02:43,950 Now, we don't need this here 54 00:02:43,950 --> 00:02:46,090 but it will become more important later 55 00:02:46,090 --> 00:02:48,350 once we talk about authentication. 56 00:02:48,350 --> 00:02:50,930 Now, I will quit this here and not go through all of that 57 00:02:50,930 --> 00:02:53,880 but you can definitely take a close look at that. 58 00:02:53,880 --> 00:02:57,880 And these again are the default node objects 59 00:02:57,880 --> 00:03:00,880 for incoming messages and for responses. 60 00:03:00,880 --> 00:03:03,760 And I'll link the documentation of these objects 61 00:03:03,760 --> 00:03:06,880 to this lecture so that you can take a closer look 62 00:03:06,880 --> 00:03:10,510 at what's in them in the official docs as well. 63 00:03:10,510 --> 00:03:12,700 And getting access to this kind of data 64 00:03:12,700 --> 00:03:15,740 can sometimes be important if you, again 65 00:03:15,740 --> 00:03:19,560 for example, needs special header or cookie data. 66 00:03:19,560 --> 00:03:21,500 And now another reason as mentioned before 67 00:03:21,500 --> 00:03:24,010 for using getServerSideProps could be 68 00:03:24,010 --> 00:03:27,810 that you don't need request or response specific data 69 00:03:27,810 --> 00:03:31,230 that you don't need to work with request or response 70 00:03:31,230 --> 00:03:34,430 but that you really wanna ensure that this function runs 71 00:03:34,430 --> 00:03:36,820 for every incoming request 72 00:03:36,820 --> 00:03:39,890 so that it's never static pre-generated. 73 00:03:39,890 --> 00:03:43,460 Because for example you have highly dynamic data 74 00:03:43,460 --> 00:03:46,010 which changes multiple times every second 75 00:03:46,010 --> 00:03:48,840 and therefore, you know, that any old page 76 00:03:48,840 --> 00:03:52,450 you would be serving would already be outdated. 77 00:03:52,450 --> 00:03:55,860 That could be another reason for using getServiceSideProps 78 00:03:56,870 --> 00:03:58,960 but as you see using it is simple. 79 00:03:58,960 --> 00:04:01,720 You can still write any server side code in there. 80 00:04:01,720 --> 00:04:05,270 You can still reach out to the dummy-backend.json file 81 00:04:05,270 --> 00:04:07,400 as we did it before, for example 82 00:04:07,400 --> 00:04:09,040 and you still return the props 83 00:04:09,040 --> 00:04:11,260 for the component function at the end. 84 00:04:11,260 --> 00:04:13,600 The only key difference is the kind of data 85 00:04:13,600 --> 00:04:15,810 you get access to in the context 86 00:04:15,810 --> 00:04:18,673 and the timing of this function. 6963

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