Update app.js
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user