All language subtitles for 002 What are _API Routes___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

Original subtitles

Now what are API routes?

It's important to understand and keep

in mind that some websites which we're building

don't just need HTML pages that are being served

back to visitors upon requests.

That of course is something which most websites need

but it's not the only thing that can be needed by a website.

You might, for example, have a feature

on your website that allows users to submit feedback

or sign up for a newsletter.

Now, when a user clicks such a button

to for example sign up for a newsletter,

you don't necessarily want to show a different page.

I mean you could show a confirmation page

that it was successful,

but you could also just show a little info pop-up

or a banner on the existing page.

But even if we ignore what we show

let's think about what happens behind the scenes

when we sign up for a newsletter.

Then we need to send data to some server

to some computer to then store that entered newsletter

email address in some database.

And that request which is being sent there

is not about fetching a site.

It is about storing data.

So it's kind of the other direction.

We don't want to get a HTML page.

Instead. We want to send that user entered data

to some database.

And that is what we use APIs for

Application Programming Interfaces.

There are different kinds of APIs we could build.

REST APIs are the most popular form of APIs.

And the idea is always the same that we have

a web server that exposes certain URLs.

Just as we did it thus far in the course

but those you are URLs are not about getting requests

and sending back HTML data,

but they are about accepting some data

and then sending back responses

with any kind of data, not necessarily HTML.

Specifically JSON, JavaScript Object Notation,

would be the most common format for exchanging such data.

So API routes are special kind of you are URLs,

which you can add to your Next.js application,

which are not about getting a standard browser request

and sending back a pre-rendered HTML page,

but which are instead about getting data, using data,

maybe storing data in some database

and sending back data in any form of your choice.

So in the end API routes, this Next.js feature

is a feature that allows us to build a API,

a REST API if you will, as part of our Next.js app.

And it would, for example, allow us to support URLs

or PRURLs after our domain, like this /apifeedback

and then accepting different kinds of HTTP requests.

Not just get requests as all our page routes did thus far

but also post or put or delete requests, whatever you need.

And then depending on which HTTP method was used

for which path, different actions could be triggered.

If, for example, for a post request send to

/api/feedback, we might expect some data

to be sent along with that incoming request

some feedback data entered by a user.

And then when that request hits our API

we extract that data from the request

and store it in a database.

If the get request reaches that same URL,

we instead might want to fetch data from a database

and send that back but not as an HTML page

but instead as raw data in that JSON format.

And those API routes, therefore don't exist to be entered

in the URL typically, but instead to be triggered

via JavaScript code, via Ajax requests.

So we as a developer add certain code

to our page that sends these behind the scenes requests

you could say to our API to store or fetch data.

And that is actually something we already did

in this course.

When we worked with Firebase, when we sent requests

to Firebase, then there, we talked to the Firebase API.

We sent requests to certain URLs

for restoring data and for getting data.

And these URLs. These Firebase URLs.

We didn't enter them into browser.

Instead we send requests through our JavaScript code.

No matter if that code then runs

on the client or on the server

we talked to that Firebase API.

And now it is API routes' feature is about letting us

to find our own API end points

as part of our Next.js application.

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