score:1

Accepted answer

just put a condition over res if it is not actually undefined

product.getall(function(res) {

        __this.setstate({ products: (res || __this.state.products) });
    });

hope it helps.

score:1

is resan array. map only works for arrays. use console.log(res) to check if it's an array it not. if not convert it to an array

score:1

the problem is at __this.setstate({ products: res }); essentially, you're getting this error because res is not of array type, so you have to check it and ensure that it is an array type as others have mentioned.

if you're still getting the same error, i suggest you console.log res and add it to your question.



Related Query

More Query from same tag