Surface the backend's actual error message instead of a generic fallback
deploy / deploy (push) Successful in 3s
deploy / deploy (push) Successful in 3s
The API already returns specific, honest messages (e.g. 'this course isn't open for signups yet' for an inactive course) — the frontend was discarding them and always showing a generic 'something went wrong'.
This commit is contained in:
@@ -41,10 +41,15 @@
|
|||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
if (!res.ok) throw new Error("request failed");
|
|
||||||
form.reset();
|
|
||||||
submitBtn.disabled = false;
|
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 () {
|
}).catch(function () {
|
||||||
submitBtn.disabled = false;
|
submitBtn.disabled = false;
|
||||||
status.textContent = "Something went wrong sending that. Try again, or email hello@reground.org directly.";
|
status.textContent = "Something went wrong sending that. Try again, or email hello@reground.org directly.";
|
||||||
|
|||||||
@@ -32,10 +32,16 @@
|
|||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ email: form.email.value })
|
body: JSON.stringify({ email: form.email.value })
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
if (!res.ok) throw new Error("request failed");
|
if (res.ok) {
|
||||||
form.reset();
|
form.reset();
|
||||||
form.hidden = true;
|
form.hidden = true;
|
||||||
status.textContent = "Check your inbox — day one is on its way.";
|
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 () {
|
}).catch(function () {
|
||||||
submitBtn.disabled = false;
|
submitBtn.disabled = false;
|
||||||
status.textContent = "Something went wrong. Try again in a moment.";
|
status.textContent = "Something went wrong. Try again in a moment.";
|
||||||
|
|||||||
Reference in New Issue
Block a user