mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-25 23:17:57 +01:00
update fetch progress code
This commit is contained in:
parent
67b4084e55
commit
635e01fd01
@ -91,14 +91,14 @@ export function fetchProgress(url, data = {}, onProgress) {
|
|||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
xhr.onload = () => {
|
xhr.onload = () => {
|
||||||
resolve(new Response(xhr.response));
|
const headers = new Headers(xhr.getAllResponseHeaders());
|
||||||
// const { status, statusText, responseURL: url } = xhr;
|
const { status, statusText, response, responseText, responseURL: url = headers.get('X-Request-URL') } = xhr;
|
||||||
// resolve(new Response(xhr.response, { status, statusText, url }));
|
resolve(new Response(response || responseText, { headers, status, statusText, url }));
|
||||||
}
|
}
|
||||||
xhr.onerror = () => reject(new TypeError('Network request failed'));
|
xhr.onerror = () => reject(new TypeError('Network request failed'));
|
||||||
xhr.ontimeout = () => reject(new TypeError('Network request failed'));
|
xhr.ontimeout = () => reject(new TypeError('Network request failed'));
|
||||||
|
|
||||||
xhr.open(request.method, url);
|
xhr.open(request.method, url, true);
|
||||||
|
|
||||||
if (request.credentials === 'include') {
|
if (request.credentials === 'include') {
|
||||||
xhr.withCredentials = true
|
xhr.withCredentials = true
|
||||||
@ -108,10 +108,9 @@ export function fetchProgress(url, data = {}, onProgress) {
|
|||||||
if (xhr.upload && onProgress) xhr.upload.onprogress = onProgress;
|
if (xhr.upload && onProgress) xhr.upload.onprogress = onProgress;
|
||||||
if (xhr.responseType) xhr.responseType = 'blob';
|
if (xhr.responseType) xhr.responseType = 'blob';
|
||||||
|
|
||||||
// Malyan printer doesn't like headers...
|
request.headers.forEach((value, name) => {
|
||||||
// request.headers.forEach((value, name) => {
|
xhr.setRequestHeader(name, value)
|
||||||
// xhr.setRequestHeader(name, value)
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
xhr.send(data.body);
|
xhr.send(data.body);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user