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 4040| 34 | [ Required Function Params] ( #Required-Function-Params ) |
4141| 35 | [ Get input value as a number] ( #Get-input-value-as-a-number ) |
4242| 36 | [ reduceRight] ( #reduceRight ) |
43+ | 37 | [ Abort Fetch] ( #AbortFetch ) |
44+
45+
46+
4347
4448
4549
@@ -775,3 +779,34 @@ const reduceRightArray = arr.reduceRight((acc, current) => {
775779
776780```
777781
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