From: Ardis Lu Date: Thu, 10 Apr 2025 03:45:47 +0000 (-0700) Subject: Wrap response in array if it is not an array X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=346bb8f911fb4e5767f27fa94ddd4ca4ebd48748;p=erc-1967-inspector 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. --- 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; }