data.map is not a function

后端 未结 9 1157
轮回少年
轮回少年 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:25

    data is not an array, it is an object with an array of products so iterate over data.products

    var allProducts = data.products.map(function (item) {
        return new getData(item);
    });
    

提交回复
热议问题