1
00:00:02,400 --> 00:00:09,030
So now we had a look at XMLHttpRequest and the fetch API, both allow us to send requests, the fetch

2
00:00:09,030 --> 00:00:12,690
APIs more modern and not supported in older browsers.

3
00:00:12,810 --> 00:00:20,880
A big plus is that it's generally easy to use and uses promises out of the box, a minus is that error

4
00:00:20,880 --> 00:00:22,850
handling can be clunky.

5
00:00:22,950 --> 00:00:27,610
Of course not the end of the world but not the most beautiful approach.

6
00:00:27,660 --> 00:00:34,770
Now arguably, that's also not that beautiful but if you hide it behind some custom function, it might

7
00:00:34,770 --> 00:00:38,270
be fine and might be a bit more straightforward to understand,

8
00:00:38,340 --> 00:00:44,090
in the end however you can also hide this behind a custom function and you're probably fine again.

9
00:00:44,280 --> 00:00:46,320
It's up to you which approach you use,

10
00:00:46,320 --> 00:00:53,790
both are fine to be used and actually another alternative which you have is that you use a third-party

11
00:00:53,790 --> 00:00:57,000
library, something we haven't really touched on yet

12
00:00:57,000 --> 00:01:05,400
which might wrap this, so the XMLHttpRequest or this fetch API approach and gives you a nicer API

13
00:01:05,430 --> 00:01:09,900
to work with, where you don't have to care about how it's implemented internally

14
00:01:10,020 --> 00:01:15,660
and that's actually something we'll have a look at in the third-party libraries module which comes right

15
00:01:15,660 --> 00:01:16,780
after this one.

16
00:01:16,920 --> 00:01:22,500
But it's important to understand how to implement this natively and often, the fetch API is great because

17
00:01:22,500 --> 00:01:28,750
it's easy to use, quick to get started and uses promises out of the box but also be aware that 

18
00:01:28,760 --> 00:01:36,360
XMLHttpRequest has better support for older browsers out of the box and in some places, regarding error

19
00:01:36,360 --> 00:01:39,690
handling specifically, might be more straightforward.
