summaryrefslogtreecommitdiff
path: root/client/js/api.js
diff options
context:
space:
mode:
authorrr- <rr-@sakuya.pl>2017-01-08 11:04:21 +0100
committerrr- <rr-@sakuya.pl>2017-01-08 11:04:49 +0100
commitecf347ef6eaa78697e4e361f2005e1ad843398c1 (patch)
treea09edce875f44dfbc5a7997d07ae8574c7324642 /client/js/api.js
parentcc969a808f253c8a6e902d27c49fab3c46b27ded (diff)
client/api: handle expired uploads
Diffstat (limited to 'client/js/api.js')
-rw-r--r--client/js/api.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/client/js/api.js b/client/js/api.js
index 766e652..6f23124 100644
--- a/client/js/api.js
+++ b/client/js/api.js
@@ -176,9 +176,17 @@ class Api extends events.EventTarget {
url, requestFactory, data, {}, options);
abortFunction = () => requestPromise.abort();
return requestPromise;
- },
- error => {
- // TODO: check if the error is because of expired uploads
+ })
+ .catch(error => {
+ 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);
});
promise.abort = () => abortFunction();