Home > other >  displaying error products.map is not a function
displaying error products.map is not a function

Time:12-04

this is my component file and when I run this code displaying error products.map is not a function.

CodePudding user response:

this means products is not an array , try console logging the products and see what it's returning . else you can make it map through only if the products exist like this

products?.map

CodePudding user response:

The .map function is only available on array. It looks like products isn't in the format you are expecting it to be (it is {} but you are expecting [])

  • Related