We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 90b171a commit 31853faCopy full SHA for 31853fa
blog/25-07-23/streaming-upload-with-fetch/ex/fetch.js
@@ -1,16 +1,17 @@
1
+
2
(async()=>{
3
4
5
var url = 'https://localhost:3010/';
6
-
7
8
var stream = new ReadableStream({start}).pipeThrough(new TextEncoderStream());
9
10
function start(ctrl){
11
12
var count = 1;
13
var timer = setTimeout(send,1000);
14
15
16
function send(){
17
console.log('send',count);
@@ -25,18 +26,18 @@
25
26
timer = setTimeout(send,1000);
27
28
}//send
29
30
}//start
31
32
33
34
35
36
var res = await fetch(url,{method:'post',body:stream,duplex:'half'});
37
var txt = await res.text();
38
console.log(txt);
39
40
41
42
43
})();
0 commit comments