1
00:00:02,120 --> 00:00:04,360
Now let's start by understanding

2
00:00:04,360 --> 00:00:08,690
what I mean when I say network and requests.

3
00:00:08,690 --> 00:00:12,230
And for this, let's assume that we have a container

4
00:00:12,230 --> 00:00:14,460
with our application inside of it,

5
00:00:14,460 --> 00:00:16,630
could be a Node application,

6
00:00:16,630 --> 00:00:18,540
could be a Python application,

7
00:00:18,540 --> 00:00:20,420
or a PHP application,

8
00:00:20,420 --> 00:00:22,080
it does not matter,

9
00:00:22,080 --> 00:00:25,930
and now let's say that this application,

10
00:00:25,930 --> 00:00:28,690
as part of its application logic,

11
00:00:28,690 --> 00:00:32,659
actually wants to talk to an API,

12
00:00:32,659 --> 00:00:36,890
so to some website out there in the World Wide Web.

13
00:00:36,890 --> 00:00:41,410
For example, to send data there or to fetch data from there,

14
00:00:41,410 --> 00:00:46,050
and just to make this clear here with this API website,

15
00:00:46,050 --> 00:00:49,630
I'm talking about a site not owned by us.

16
00:00:49,630 --> 00:00:53,250
So this is not another container or anything like that,

17
00:00:53,250 --> 00:00:56,570
it's just a website, a web API,

18
00:00:56,570 --> 00:00:59,940
to which your application might want to talk.

19
00:00:59,940 --> 00:01:03,560
It might want to send a GET HTTP request

20
00:01:03,560 --> 00:01:05,840
to this API, for example.

21
00:01:05,840 --> 00:01:10,120
So this scenario here would be about sending a request,

22
00:01:10,120 --> 00:01:14,860
in this case, an HTTP request, from your container,

23
00:01:14,860 --> 00:01:17,960
so from the application running in a container

24
00:01:17,960 --> 00:01:19,423
to the World Wide Web.

25
00:01:20,480 --> 00:01:23,330
And I actually do have an example for this.

26
00:01:23,330 --> 00:01:26,770
Attached, you'll find another simple starting project.

27
00:01:26,770 --> 00:01:29,040
It's another Node.js application,

28
00:01:29,040 --> 00:01:31,300
but again, it's just an example.

29
00:01:31,300 --> 00:01:33,610
I tend to use Node.js a lot

30
00:01:33,610 --> 00:01:35,380
because I work with it a lot,

31
00:01:35,380 --> 00:01:38,550
but you could have any kind of application,

32
00:01:38,550 --> 00:01:41,760
but in this application, I'm doing something special.

33
00:01:41,760 --> 00:01:44,170
In there in this app.js file,

34
00:01:44,170 --> 00:01:46,290
which holds my application code,

35
00:01:46,290 --> 00:01:50,430
I am using Axios, which is a third party package,

36
00:01:50,430 --> 00:01:54,940
which has also mentioned in package.json as a dependency.

37
00:01:54,940 --> 00:01:56,890
I'm using Axios to send a GET request

38
00:01:57,805 --> 00:02:00,923
to this Star Wars API here.

39
00:02:01,960 --> 00:02:06,400
And this is not an API created or owned by me.

40
00:02:06,400 --> 00:02:08,160
It's not a Docker container.

41
00:02:08,160 --> 00:02:10,830
It's a website in the end, a web API,

42
00:02:10,830 --> 00:02:12,340
which you can also visit.

43
00:02:12,340 --> 00:02:17,340
For example, swapi.dev/api/films will yield some data,

44
00:02:18,410 --> 00:02:22,260
some information about the Star Wars movies.

45
00:02:22,260 --> 00:02:25,480
So this is simply a dummy API, you could say,

46
00:02:25,480 --> 00:02:27,940
which we can use to play around with it

47
00:02:27,940 --> 00:02:30,230
in dummy demo applications,

48
00:02:30,230 --> 00:02:33,470
and that is the kind of application we have here.

49
00:02:33,470 --> 00:02:37,870
This application here will actually create another API,

50
00:02:37,870 --> 00:02:40,680
which then will live in a container later,

51
00:02:40,680 --> 00:02:43,080
but under the hood, this API,

52
00:02:43,080 --> 00:02:44,350
which I'm building here,

53
00:02:44,350 --> 00:02:46,770
will reach out to another API,

54
00:02:46,770 --> 00:02:49,840
this Star Wars API to fetch movie

55
00:02:49,840 --> 00:02:52,600
and character data from there.

56
00:02:52,600 --> 00:02:56,100
Now, I'll dig deeper into this example application

57
00:02:56,100 --> 00:02:57,370
in just a second,

58
00:02:57,370 --> 00:03:01,050
because we are going to work with it throughout this module,

59
00:03:01,050 --> 00:03:03,180
but I just want to highlight already

60
00:03:03,180 --> 00:03:05,380
that this is a Node application

61
00:03:05,380 --> 00:03:09,310
that sends an HTTP request to some other site,

62
00:03:09,310 --> 00:03:11,500
to some other website in this case,

63
00:03:11,500 --> 00:03:15,460
and therefore will definitely have HTTP communication

64
00:03:15,460 --> 00:03:20,460
between this app and this Star Wars API website.

65
00:03:20,480 --> 00:03:22,320
And that of course implies

66
00:03:22,320 --> 00:03:25,770
that if we put this Node app into a container,

67
00:03:25,770 --> 00:03:27,870
which we're going to do in this module,

68
00:03:27,870 --> 00:03:32,040
we need to ensure that this request can still be sent

69
00:03:32,040 --> 00:03:35,840
and that it can go from inside our container

70
00:03:35,840 --> 00:03:38,180
to outside the container.

71
00:03:38,180 --> 00:03:41,410
So that is one possible way of communicating

72
00:03:41,410 --> 00:03:42,910
in a dockerized app,

73
00:03:42,910 --> 00:03:47,080
sending an HTTP request to some other website or web API,

74
00:03:47,080 --> 00:03:48,073
which is out there.

