← back to Dw Hero Admin
fix: api() rejects on non-2xx HTTP so .catch handlers fire; add noopener,noreferrer to open-live-site window
23d9290ed44dabdf63c623b1924f06e0efadde93 · 2026-05-18 20:24:12 -0700 · SteveStudio2
Files touched
Diff
commit 23d9290ed44dabdf63c623b1924f06e0efadde93
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Mon May 18 20:24:12 2026 -0700
fix: api() rejects on non-2xx HTTP so .catch handlers fire; add noopener,noreferrer to open-live-site window
---
public/index.html | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/public/index.html b/public/index.html
index 8b766ef..3a75cf3 100644
--- a/public/index.html
+++ b/public/index.html
@@ -199,7 +199,18 @@
brandMenu: document.getElementById('brandMenu'),
};
- function api(url, opts) { return fetch(url, opts).then(function (r) { return r.json(); }); }
+ function api(url, opts) {
+ return fetch(url, opts).then(function (r) {
+ return r.json().catch(function () { return {}; }).then(function (body) {
+ if (!r.ok) {
+ var err = new Error((body && body.error) || ('HTTP ' + r.status));
+ err.body = body;
+ throw err;
+ }
+ return body;
+ });
+ });
+ }
function loadSites() {
return api('/api/sites').then(function (data) {
@@ -525,7 +536,7 @@
});
els.openSiteBtn.addEventListener('click', function () {
- if (state.site) window.open('https://' + state.site + '.com', '_blank');
+ if (state.site) window.open('https://' + state.site + '.com', '_blank', 'noopener,noreferrer');
});
els.siteSearch.addEventListener('input', function () {
← 0ac6205 chore: add tmp/ to .gitignore per standing rule
·
back to Dw Hero Admin
·
dw-hero-admin: schema-validate /api/site/:site/grid POST (Ti a1841b6 →