client/api: handle expired uploads

This commit is contained in:
rr- 2017-01-08 11:04:21 +01:00
parent cc969a808f
commit ecf347ef6e

View file

@ -176,9 +176,17 @@ class Api extends events.EventTarget {
url, requestFactory, data, {}, options); url, requestFactory, data, {}, options);
abortFunction = () => requestPromise.abort(); abortFunction = () => requestPromise.abort();
return requestPromise; return requestPromise;
}, })
error => { .catch(error => {
// TODO: check if the error is because of expired uploads if (error.response.name ===
'MissingOrExpiredRequiredFileError') {
for (let key of Object.keys(files)) {
files[key].token = null;
}
error.message =
'The uploaded file has expired; ' +
'please resend the form to reupload.';
}
return Promise.reject(error); return Promise.reject(error);
}); });
promise.abort = () => abortFunction(); promise.abort = () => abortFunction();