diff --git a/app.js b/app.js index eb04999..fd65232 100644 --- a/app.js +++ b/app.js @@ -1375,18 +1375,11 @@ async function crmLoadRecords() { }); if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`); const json = await res.json(); - // Normalise: response may be [[{...},...]] or [{...},...] or {response:[...]} - let data; - if (Array.isArray(json)) { - if (json.length > 0 && Array.isArray(json[0])) { - data = json[0]; - } else { - data = json; - } - } else if (json && json.response) { - data = json.response; - } else { - data = []; + // Shape: {data: [{...}, ...]} + let data = json?.data ?? json?.response ?? json; + // If the outer result wraps in an extra array like [{data:[...]}] handle that too + if (Array.isArray(data) && data.length > 0 && data[0]?.data) { + data = data[0].data; } crmRecords = Array.isArray(data) ? data : []; crmRender();