guard text.js node fetch on non-ok response

This commit is contained in:
Yisroel Baum 2026-05-03 17:32:48 +03:00
parent 33668e2930
commit 17ab181adb
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -32,8 +32,15 @@ document.addEventListener('DOMContentLoaded', () => {
function fetchAndRenderNodes(textId) {
return fetch('/api/nodes/' + textId, { credentials: 'same-origin' })
.then(res => res.json())
.then(function (response) {
if (!response.ok) {
return null;
}
return response.json();
})
.then(nodes => {
if (!Array.isArray(nodes)) return;
const existing = document.querySelector('#text-detail > ul');
if (existing) existing.remove();