Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,740 --> 00:00:04,890
In the last section, we imported just the jet function into our Abdah Dart file.
2
00:00:05,390 --> 00:00:12,800
So now we're ready to use that jet function to make a request over to that JSON API endpoint inside
3
00:00:12,800 --> 00:00:14,320
of my FETs image method right here.
4
00:00:14,570 --> 00:00:20,480
I'm going to call get the first argument to the jet function is the URL that we want to make a request
5
00:00:20,480 --> 00:00:20,810
to.
6
00:00:21,640 --> 00:00:27,560
To get that Yoro, I'm going to go back over to my browser where I still have the JSON placeholder type
7
00:00:27,560 --> 00:00:30,780
I code dot com you URL inside of my address bar.
8
00:00:31,330 --> 00:00:32,530
So I'm going to copy this.
9
00:00:32,530 --> 00:00:33,370
You are all right here.
10
00:00:34,460 --> 00:00:40,160
And then I will put it in as the first argument to my get function as a string like so.
11
00:00:41,720 --> 00:00:47,930
Now, if we make a request to photos that's going to retrieve all five thousand photos that are posted
12
00:00:47,930 --> 00:00:51,210
at the CPI and that's definitely not what we want to do.
13
00:00:51,560 --> 00:00:54,830
We only want to get one specific photo at a time.
14
00:00:55,250 --> 00:00:58,970
So to indicate which photo we want, I'm going to put a slash at the very end.
15
00:00:59,030 --> 00:01:01,800
Oops, slash at the very end.
16
00:01:01,820 --> 00:01:02,360
There we go.
17
00:01:02,600 --> 00:01:05,540
And then we'll write out the ID of the photo that we want to fetch.
18
00:01:06,050 --> 00:01:11,030
So chances are that we want to start with the ID of one, because that's the first photo there is inside
19
00:01:11,030 --> 00:01:11,750
this collection.
20
00:01:12,020 --> 00:01:15,210
And then get photo two, three, four, five and so on.
21
00:01:15,920 --> 00:01:19,850
So for that, we can reuse the counter variable that we had previously created.
22
00:01:20,330 --> 00:01:25,880
Remember, we start off counter as zero and then every time a user presses the button, we will increment
23
00:01:25,880 --> 00:01:27,260
that counter variable by one.
24
00:01:28,270 --> 00:01:34,120
So I'm going to use a little bit of string interpolation here and I'll put on counter at the very end.
25
00:01:35,730 --> 00:01:41,490
But you'll notice that any time that counter is initialized inside of our asset class, it starts off
26
00:01:41,490 --> 00:01:45,510
as zero and there is no photo with ID of zero.
27
00:01:45,960 --> 00:01:51,770
If we go back to that photos endpoint, the first photo inside the collection has an idea of one.
28
00:01:52,560 --> 00:01:57,990
So I'm going to make sure that I don't try to get a photo with idea of zero by just incrementing the
29
00:01:57,990 --> 00:02:01,530
counter variable by one right before we make that request.
30
00:02:02,680 --> 00:02:06,220
So we can absolutely increment countered by one by using the syntax right here.
31
00:02:07,260 --> 00:02:12,510
We could also write out simply counter plus plus, which has the same effect, counter plus plus will
32
00:02:12,510 --> 00:02:14,250
increment the counter variable by one.
33
00:02:15,510 --> 00:02:20,350
OK, so that looks pretty good now before we try to test out anything here.
34
00:02:20,580 --> 00:02:26,040
There's one thing I want to remind you about that I very briefly pointed out in the last section, if
35
00:02:26,040 --> 00:02:32,400
we go back over to the documentation for our dysfunction, here is the jet function we pass in the URL
36
00:02:32,400 --> 00:02:33,590
as the first argument.
37
00:02:33,960 --> 00:02:39,180
You'll remember that I mentioned that the jet function returns something called a future.
38
00:02:39,720 --> 00:02:44,700
So we need to have a quick discussion about what a future is, because it's a very important concept
39
00:02:44,700 --> 00:02:48,660
that's going to come up many, many times throughout all the other applications that we're going to
40
00:02:48,660 --> 00:02:49,500
build in this course.
41
00:02:49,950 --> 00:02:53,910
So we'll take a quick break, come back the next section and talk about what a future is.
4212
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.