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.
}).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;
}
}).then(r => r.json());
let recurseAddress = null;
- for (const item of response) {
+ for (const item of [response].flat()) {
if (item?.result === undefined) {
continue;
}