diff --git a/layouts/_default/contact.html b/layouts/_default/contact.html index ed81810..5b15b72 100644 --- a/layouts/_default/contact.html +++ b/layouts/_default/contact.html @@ -41,10 +41,15 @@ headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }).then(function (res) { - if (!res.ok) throw new Error("request failed"); - form.reset(); submitBtn.disabled = false; - status.textContent = "Thanks — I'll get back to you soon."; + if (res.ok) { + form.reset(); + status.textContent = "Thanks — I'll get back to you soon."; + return; + } + return res.text().then(function (msg) { + status.textContent = msg || "Something went wrong sending that. Try again, or email hello@reground.org directly."; + }); }).catch(function () { submitBtn.disabled = false; status.textContent = "Something went wrong sending that. Try again, or email hello@reground.org directly."; diff --git a/layouts/courses/single.html b/layouts/courses/single.html index a8a5ff0..e4e4be1 100644 --- a/layouts/courses/single.html +++ b/layouts/courses/single.html @@ -32,10 +32,16 @@ headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: form.email.value }) }).then(function (res) { - if (!res.ok) throw new Error("request failed"); - form.reset(); - form.hidden = true; - status.textContent = "Check your inbox — day one is on its way."; + if (res.ok) { + form.reset(); + form.hidden = true; + status.textContent = "Check your inbox — day one is on its way."; + return; + } + return res.text().then(function (msg) { + submitBtn.disabled = false; + status.textContent = msg || "Something went wrong. Try again in a moment."; + }); }).catch(function () { submitBtn.disabled = false; status.textContent = "Something went wrong. Try again in a moment.";