Update app.js
This commit is contained in:
@@ -1131,13 +1131,13 @@ async function loadInvoices() {
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
let data = await res.json();
|
||||
dbg("\u2190 Invoices", data);
|
||||
// unwrap n8n envelope: [{json:{...}}] → [{...}]
|
||||
if (Array.isArray(data)) {
|
||||
// unwrap envelope: {data:[...]} or [{json:{...}}] or plain array
|
||||
if (data && !Array.isArray(data) && Array.isArray(data.data)) {
|
||||
data = data.data;
|
||||
} else if (Array.isArray(data)) {
|
||||
data = data.map((item) =>
|
||||
item && typeof item === "object" && "json" in item ? item.json : item,
|
||||
);
|
||||
} else if (data && typeof data === "object" && "json" in data) {
|
||||
data = [data.json];
|
||||
} else {
|
||||
data = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user