diff --git a/frontend/js/app/api.js b/frontend/js/app/api.js index baa5cb1..9d11d26 100644 --- a/frontend/js/app/api.js +++ b/frontend/js/app/api.js @@ -139,7 +139,11 @@ function FileUpload(path, fd) { xhr.onreadystatechange = function () { if (this.readyState === XMLHttpRequest.DONE) { if (xhr.status !== 200 && xhr.status !== 201) { - reject(new Error('Upload failed: ' + xhr.status)); + try { + reject(new Error('Upload failed: ' + JSON.parse(xhr.responseText).error.message)); + } catch (err) { + reject(new Error('Upload failed: ' + xhr.status)); + } } else { resolve(xhr.responseText); } @@ -587,7 +591,8 @@ module.exports = { * @param {Object} data */ create: function (data) { - const timeout = 180000 + (data.meta.propagation_seconds ? Number(data.meta.propagation_seconds) * 1000 : 0); + + const timeout = 180000 + (data && data.meta && data.meta.propagation_seconds ? Number(data.meta.propagation_seconds) * 1000 : 0); return fetch('post', 'nginx/certificates', data, {timeout}); }, diff --git a/frontend/js/app/nginx/certificates/form.ejs b/frontend/js/app/nginx/certificates/form.ejs index 270ab71..4e40e0b 100644 --- a/frontend/js/app/nginx/certificates/form.ejs +++ b/frontend/js/app/nginx/certificates/form.ejs @@ -4,17 +4,14 @@