1
00:00:00,420 --> 00:00:05,400
Hey, hey, I know that we do have a working model and there are some tweaks, and it just means that

2
00:00:05,400 --> 00:00:09,870
you can do to your code and this lesson is going to show you another one that we can do in order to

3
00:00:09,870 --> 00:00:11,600
make it run a little bit more efficiently.

4
00:00:11,880 --> 00:00:13,980
So we've got promises within Futch.

5
00:00:14,130 --> 00:00:21,030
And instead of having data one, we can get out of this and just do a return and pass this over.

6
00:00:21,040 --> 00:00:29,280
So getting that data items map when we return it, it can return that back into the next promise and

7
00:00:29,280 --> 00:00:31,130
then that's where we can handle the show.

8
00:00:31,770 --> 00:00:38,970
So bringing that all in and we've got the return of the items map and then that is returning from the

9
00:00:38,970 --> 00:00:39,230
map.

10
00:00:39,240 --> 00:00:44,040
So I know we've got to return there, but it is important to understand that there's a number of different

11
00:00:44,040 --> 00:00:45,080
ways to present this.

12
00:00:45,390 --> 00:00:52,290
So if we get another promise at the end and then this will be our new array object, and then you can

13
00:00:52,290 --> 00:00:58,180
call that, of course, anything you want, and we can pass this into our show if we want to.

14
00:00:58,590 --> 00:01:06,390
So here, once this has completed, then this promise will go and we can pass in the array data and

15
00:01:06,390 --> 00:01:09,500
there's also an option to catch any errors.

16
00:01:09,780 --> 00:01:15,840
So it's also a good idea to include with any fetch just in case you are throwing errors and you want

17
00:01:15,840 --> 00:01:21,210
to see what the error is so doesn't catch you off guard, you can use a catch and console log at the

18
00:01:21,210 --> 00:01:21,500
air.

19
00:01:21,510 --> 00:01:27,180
So this will only only show if there's any major errors and to the connection.

20
00:01:27,190 --> 00:01:32,060
So otherwise it's not going to show so that we can try that once again and it should do the same thing.

21
00:01:32,070 --> 00:01:32,880
Nothing's changed.

22
00:01:33,100 --> 00:01:37,820
It's the exact same thing, except that we're catching errors and we just restructured the fetch.

23
00:01:38,130 --> 00:01:39,390
So this is another option.

24
00:01:39,810 --> 00:01:44,430
You don't have to include this, but you can include it if you want in order to make your code a little

25
00:01:44,430 --> 00:01:45,270
bit more presentable.

26
00:01:45,390 --> 00:01:51,480
So coming up next, there's also an option of the data that's being returned back where we can get the

27
00:01:51,480 --> 00:01:53,730
next the next page.

28
00:01:54,120 --> 00:02:00,300
So you see in this large object, we've got a next page token and then this is how we can get to the

29
00:02:00,300 --> 00:02:01,200
next page.

30
00:02:01,350 --> 00:02:05,060
So if we do this next page token and add that in.

31
00:02:05,070 --> 00:02:10,090
So if we copy that and we put into the URL and this is fairly long.

32
00:02:10,380 --> 00:02:17,700
So at the end here and we do an end page token and then equal that to whatever the page token value

33
00:02:17,700 --> 00:02:22,590
was, you're going to see that it's going to move to the next page and then always going to have a next

34
00:02:22,590 --> 00:02:23,210
page token.

35
00:02:23,220 --> 00:02:24,870
It's kind of a previous page token.

36
00:02:25,020 --> 00:02:29,400
So you can see that all of these tokens are different and these are representing the different pages.

37
00:02:29,560 --> 00:02:34,130
You can create some page pagination between your content so you can move it to the next page.

38
00:02:34,140 --> 00:02:35,430
I'll show you how to do that coming up.
