Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,120 --> 00:00:03,170
Now, I prepared
2
00:00:03,170 --> 00:00:05,610
another dummy application for you.
3
00:00:05,610 --> 00:00:07,860
Of course, you find it attached.
4
00:00:07,860 --> 00:00:12,340
It has two dummy movies, which are being rendered here
5
00:00:12,340 --> 00:00:15,480
and this button, which currently doesn't do anything.
6
00:00:15,480 --> 00:00:18,520
Now, the code for this is fairly straightforward.
7
00:00:18,520 --> 00:00:20,640
It's an app component, which renders
8
00:00:20,640 --> 00:00:22,370
a section with this button
9
00:00:22,370 --> 00:00:25,400
and which then renders a MoviesList component.
10
00:00:25,400 --> 00:00:28,300
And, currently, I just have some dummy movie data
11
00:00:28,300 --> 00:00:31,032
which has fed into the MoviesList.
12
00:00:31,032 --> 00:00:34,190
And in the MoviesList, I simply loop through
13
00:00:34,190 --> 00:00:37,780
these movies to output the individual movie components,
14
00:00:37,780 --> 00:00:41,220
which render list items with, well, this content
15
00:00:41,220 --> 00:00:44,700
and that brings this here to the screen.
16
00:00:44,700 --> 00:00:47,990
Now at this point in this application, as I said,
17
00:00:47,990 --> 00:00:50,630
we're just using some dummy data here.
18
00:00:50,630 --> 00:00:53,530
I wanna change just now, I wanna fetch data
19
00:00:53,530 --> 00:00:57,393
from a database which contains some example movies.
20
00:00:58,360 --> 00:01:02,030
And for that, I'll use The Star Wars API.
21
00:01:02,030 --> 00:01:07,030
You can visit swapi.dev for Star Wars API.
22
00:01:07,060 --> 00:01:10,430
And here you have a little dummy API
23
00:01:10,430 --> 00:01:13,680
with some dummy data which you can send requests to,
24
00:01:13,680 --> 00:01:16,190
to play around with it, basically.
25
00:01:16,190 --> 00:01:19,270
Now, I will say right away, this is an API.
26
00:01:19,270 --> 00:01:22,300
It's a backend app, it's not a database
27
00:01:22,300 --> 00:01:25,640
because of what I explained in the last section.
28
00:01:25,640 --> 00:01:28,740
Behind the scenes it, of course, probably uses
29
00:01:28,740 --> 00:01:33,070
some database to store some data about the Star Wars movies
30
00:01:33,070 --> 00:01:35,860
but we interact with this backend app.
31
00:01:35,860 --> 00:01:39,300
And I said API a couple of times.
32
00:01:39,300 --> 00:01:43,930
API stands for application programming interface.
33
00:01:43,930 --> 00:01:47,380
And it's a very broad term not just related
34
00:01:47,380 --> 00:01:50,600
to React and HTTP requests, in the end,
35
00:01:50,600 --> 00:01:52,680
it means that in our code we're dealing
36
00:01:52,680 --> 00:01:56,640
with something which has a clearly defined interface,
37
00:01:56,640 --> 00:02:01,330
clearly defined rules on how we can achieve certain results
38
00:02:01,330 --> 00:02:04,160
and do certain tasks, and when we talk
39
00:02:04,160 --> 00:02:08,520
about APIs in the context of HTTP requests
40
00:02:08,520 --> 00:02:12,650
we typically talk about REST or GraphQL APIs,
41
00:02:12,650 --> 00:02:15,400
which are basically two different standards
42
00:02:15,400 --> 00:02:18,810
for how a server should expose its data.
43
00:02:18,810 --> 00:02:21,540
Now, this is a REST API, and it simply means
44
00:02:21,540 --> 00:02:23,740
that there are a couple of URLs,
45
00:02:23,740 --> 00:02:26,120
like this URL which you see here,
46
00:02:26,120 --> 00:02:27,780
to which you send that request
47
00:02:27,780 --> 00:02:30,370
to get back data in a certain format.
48
00:02:30,370 --> 00:02:34,450
And different URLs to which you send different requests
49
00:02:34,450 --> 00:02:36,980
will give you different chunks of data.
50
00:02:36,980 --> 00:02:38,880
That's what makes it an API.
51
00:02:38,880 --> 00:02:40,850
You got different entry points,
52
00:02:40,850 --> 00:02:43,240
which lead to different results.
53
00:02:43,240 --> 00:02:45,990
If you want to learn more about REST APIs
54
00:02:45,990 --> 00:02:47,690
and what exactly that all is,
55
00:02:47,690 --> 00:02:49,840
you also find a helpful resource
56
00:02:49,840 --> 00:02:52,670
on that attached to this lecture.
57
00:02:52,670 --> 00:02:54,700
So, here, we can basically send the request
58
00:02:54,700 --> 00:02:58,080
to this URL, for example, to get information
59
00:02:58,080 --> 00:03:02,200
about a certain person from the Star Wars movies.
60
00:03:02,200 --> 00:03:04,900
We can also grab this URL here
61
00:03:04,900 --> 00:03:09,900
and send the request to swapi.dev/API/films.
62
00:03:10,220 --> 00:03:12,120
And we will later get back a response
63
00:03:12,120 --> 00:03:15,960
with a bunch of objects describing the different films,
64
00:03:15,960 --> 00:03:19,510
the different Star Wars movies with, for example,
65
00:03:19,510 --> 00:03:22,980
the opening crawl text and the title,
66
00:03:22,980 --> 00:03:25,720
the episode ID, and so on.
67
00:03:25,720 --> 00:03:28,420
Now, this is just a dummy API, which I want to use
68
00:03:28,420 --> 00:03:32,290
for getting started with sending HTTP requests.
69
00:03:32,290 --> 00:03:35,000
That's why I'm having a look at this first.
70
00:03:35,000 --> 00:03:38,370
And this is the API to which we now want to send requests
71
00:03:38,370 --> 00:03:41,160
from inside our React application here
72
00:03:41,160 --> 00:03:44,340
to populate this list of movies here
73
00:03:44,340 --> 00:03:47,450
with some real data instead of our dummy data.
74
00:03:47,450 --> 00:03:50,533
And how does this, now, work in React?
5939
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.