From 346bb8f911fb4e5767f27fa94ddd4ca4ebd48748 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 9 Apr 2025 20:45:47 -0700 Subject: [PATCH] Wrap response in array if it is not an array Some RPC providers (e.g., Google Blockchain RPC) will respond with a single object on error, which is not compliant with the JSON-RPC spec. Wrapping the response in an array then flattening ensures the result is an iterable, one-dimensional array. --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 839961a..f8b73c3 100644 --- a/index.html +++ b/index.html @@ -162,7 +162,7 @@ }).then(r => r.json()); let recurseAddress = null; - for (const item of response) { + for (const item of [response].flat()) { if (item?.result === undefined || Number(item.result) === 0) { continue; } @@ -223,7 +223,7 @@ }).then(r => r.json()); let recurseAddress = null; - for (const item of response) { + for (const item of [response].flat()) { if (item?.result === undefined) { continue; } -- 2.47.3