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