response.data !== undefined && response.data.length > 0 The condition should check:
- Is there an "data" array?
- Does it have meaning?
response.data !== undefined && response.data.length > 0 The condition should check:
Checking for undefined is not enough. So there may not be an array, but any value, for example, null. You need to check that this is really an array and then check the size.
var data = response.data; if(Object.prototype.toString.call(data) == "[object Array]" && data.length > 0) { // data - это массив и в нем есть элементы } = - Grundyundefined > 0 === false - GrundyArray.isArray(...) , instead of the prototype? - YuriSource: https://ru.stackoverflow.com/questions/618468/
All Articles