multimodalart HF Staff commited on
Commit
f366cad
·
1 Parent(s): ddc2532

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +12 -4
index.html CHANGED
@@ -53,6 +53,7 @@
53
  let progressMap = new Map();
54
 
55
  fetch = (url, init) => {
 
56
  if (init.method === 'PUT') {
57
  return new Promise((resolve, reject) => {
58
  const xhr = new XMLHttpRequest();
@@ -64,11 +65,18 @@
64
  }
65
 
66
  xhr.onload = () => {
67
- const init = { "status" : xhr.status , "statusText" : xhr.statusText };
68
- const blob = new Blob([xhr.response], {type : 'text/plain'});
69
- const response = new Response(blob, init);
70
- resolve(response);
 
 
 
 
 
 
71
  };
 
72
 
73
  xhr.onerror = () => reject(new TypeError('Network request failed'));
74
  xhr.ontimeout = () => reject(new TypeError('Network request failed due to timeout'));
 
53
  let progressMap = new Map();
54
 
55
  fetch = (url, init) => {
56
+ console.log(url, init)
57
  if (init.method === 'PUT') {
58
  return new Promise((resolve, reject) => {
59
  const xhr = new XMLHttpRequest();
 
65
  }
66
 
67
  xhr.onload = () => {
68
+ resolve({
69
+ ok: xhr.status >= 200 && xhr.status < 300,
70
+ status: xhr.status,
71
+ statusText: xhr.statusText,
72
+ text: () => Promise.resolve(xhr.responseText),
73
+ json: () => Promise.resolve(JSON.parse(xhr.responseText)),
74
+ headers: {
75
+ get: (header) => xhr.getResponseHeader(header)
76
+ }
77
+ });
78
  };
79
+
80
 
81
  xhr.onerror = () => reject(new TypeError('Network request failed'));
82
  xhr.ontimeout = () => reject(new TypeError('Network request failed due to timeout'));