0

I have a validation that executes a lot of times. Basically I'm trying to check if the data has the same keys as the headers.length. data size can be like 1 million length

"errorType": "RangeError",
    "errorMessage": "Maximum call stack size exceeded",
    "stack": [
        "RangeError: Maximum call stack size exceeded",     

Code:

    isValid: function (headers, data) {

        const dataTotalKeys = Math.min(...data.map((el) => Object.keys(el).length)); // ERROR HERE!!
        return headers.length === dataTotalKeys;
}

I think the issue is the ... but if I remove the ... from data I get NaN

Why this error happens and how do I fix this?

asfafafags
  • 99
  • 5

0 Answers0