Skip to content

Commit f3233ab

Browse files
authored
Abort Fetch
1 parent bae6599 commit f3233ab

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
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+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy