|
@@ -11,13 +11,15 @@ function makeArvadosRequest(arvHost, arvToken, endpoint, params={}) { |
|
|
'useSsl': true,
|
|
|
'useSsl': true,
|
|
|
'requireToken': true,
|
|
|
'requireToken': true,
|
|
|
'onProgress': () => {},
|
|
|
'onProgress': () => {},
|
|
|
'promiseOrdering': true
|
|
|
|
|
|
|
|
|
'promiseOrdering': true,
|
|
|
|
|
|
'expectedStatus': 200
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
Object.keys(defaultParams).map(k => (params[k] =
|
|
|
Object.keys(defaultParams).map(k => (params[k] =
|
|
|
(k in params ? params[k] : defaultParams[k])));
|
|
|
(k in params ? params[k] : defaultParams[k])));
|
|
|
let { method, data, contentType, responseType,
|
|
|
let { method, data, contentType, responseType,
|
|
|
useSsl, requireToken, onProgress, promiseOrdering } = params;
|
|
|
|
|
|
|
|
|
useSsl, requireToken, onProgress, promiseOrdering,
|
|
|
|
|
|
expectedStatus } = params;
|
|
|
|
|
|
|
|
|
if (!(arvHost && (arvToken || !requireToken)))
|
|
|
if (!(arvHost && (arvToken || !requireToken)))
|
|
|
return new Promise((accept, reject) => reject());
|
|
|
return new Promise((accept, reject) => reject());
|
|
@@ -36,7 +38,7 @@ function makeArvadosRequest(arvHost, arvToken, endpoint, params={}) { |
|
|
xhr.onreadystatechange = () => {
|
|
|
xhr.onreadystatechange = () => {
|
|
|
if (xhr.readyState !== 4)
|
|
|
if (xhr.readyState !== 4)
|
|
|
return;
|
|
|
return;
|
|
|
if (xhr.status !== 200)
|
|
|
|
|
|
|
|
|
if (xhr.status !== expectedStatus)
|
|
|
reject(xhr);
|
|
|
reject(xhr);
|
|
|
else
|
|
|
else
|
|
|
accept(xhr);
|
|
|
accept(xhr);
|
|
|