TypeError: x is not iterable or cannot read Symbol.iterator

The value passed to array spread or for...of has no usable iterator. A plain object such as { a: 1 } can have properties without implementing Symbol.iterator. Some engines name that property in the error message.
Pause where the value is spread or looped over. An API response may wrap the array in a field. If the caller requires an array, check with Array.isArray(). If it accepts any iterable, a Set or a Map can also be valid. Use Object.entries() when you want the keys and values from a dictionary.
The spread in the first try block fails with TypeError. The loop below it walks an array of [key, value] pairs created from the same object. Choose that conversion only if the loop should receive pairs.
const record = { a: 1, b: 2 }; try { console.log([…record]); } catch (error) { console.log(error.name); // TypeError } for (const [key, value] of Object.entries(record)) { console.log(key, value); // a 1, then b 2 }
Pass an array and a plain object to the failing function. Decide whether the object should be rejected or converted to entries.