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