data.map is not a function

后端 未结 9 1113
轮回少年
轮回少年 2020-12-02 05:50

I\'m bashing my head against an error I can\'t work out how to fix. I have the following;

JSON

{\"products\":
[
    {
        \"product_id\" : \"123         


        
9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 06:35

    Objects, {} in JavaScript does not have the method .map(). It's only for Arrays, [].

    So in order for your code to work change data.map() to data.products.map() since products is an array which you can iterate upon.

提交回复
热议问题