From fc90204d97c13d2da198848758d365bcdd2fb743 Mon Sep 17 00:00:00 2001 From: oliver Date: Tue, 9 Jun 2026 14:09:55 -0300 Subject: [PATCH] Update app.js --- app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index b01af7a..424bfcf 100644 --- a/app.js +++ b/app.js @@ -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 = []; }