File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 40
40
|34 | [Required Function Params](#Required-Function-Params)|
41
41
|35 | [Get input value as a number](#Get-input-value-as-a-number)|
42
42
|36 | [reduceRight](#reduceRight)|
43
+ |37 | [Abort Fetch](#AbortFetch)|
44
+
45
+
46
+
43
47
44
48
45
49
@@ -775,3 +779,34 @@ const reduceRightArray = arr.reduceRight((acc, current) => {
775
779
776
780
```
777
781
782
+
783
+
784
+ ```
785
+ **[⬆ Back to Top](#table-of-contents)**
786
+ ### Abort Fetch
787
+
788
+ ```javascript
789
+
790
+
791
+ //HTML
792
+ <button id="download">Download</button>
793
+ <button id="abort">Abort</button>
794
+
795
+ //JS
796
+ let controller;
797
+
798
+ document.querySelector('#download').addEventListener('click', () => {
799
+ controller = new AbortController();
800
+ const signal = controller.signal;
801
+ fetch('https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4', {signal})
802
+ .then(() => console.log('done'));
803
+ });
804
+
805
+ document.querySelector('#abort').addEventListener('click', function() {
806
+ controller.abort();
807
+ });
808
+
809
+ ```
810
+
811
+
812
+
You can’t perform that action at this time.
0 commit comments