TypeError: response.data.forEach is not a function

problem description

there are a lot of TypeEroor errors, which feels like an error in front-end vue rendering, but I am a vue rookie and don"t know how to handle it.

the environmental background of the problems and what methods you have tried

the front end requests all the categories and the information in the shopping cart. You can see the classified data allMenuLabel and shopping cart product information good_lists.
vue Devtools
TypeError:

  1. TypeError: response.data.forEach is not a function
  2. TypeError: Cannot read property "id" of null.
  3. vue.common.js:1743 TypeError: Cannot read property "id" of undefined

TypeError

8:

allMenuLabel2property "id" of null:



TypeError3(property "id" of undefined)

in the vue plug-in (vue Devtools).

what result do you expect? What is the error message actually seen?

at the beginning of development (local environment), the data can still be displayed, but I don"t know if I switched to the remote server and found that it was wrong, changed to the local environment, or could not be displayed. I was worried about the impact of the original data, so I emptied the data of the shopping cart and added some data. It still didn"t work. I began to wonder if my vue version was wrong.
I have done tests on other pages, all due to rendering errors or assignment reasons. The back-end data has been brought in, but it is not possible to parse. I hope the experienced seniors will give me some advice! I"m much obliged!


TypeError: response.data.forEach is not a function

response.data is not an array, so there is no forEach method. Response.data.results is the array you need.

TypeError: Cannot read property 'id' of null.

allMenuLabel does not have the field id, so you will naturally report an error

.
vue.common.js:1743 TypeError: Cannot read property 'id' of undefined
<dl v-if="goods_list" v-for="(item,index) in goods_list.goods_list">
                                <dt><router-link :to="'/app/home/productDetail/'+item.goods.id" target = _blank><img :src="item.goods.goods_front_image"></router-link></dt>
                                <dd>
                                  <h4><router-link :to="'/app/home/productDetail/'+item.goods.id" target = _blank>{{item.goods.name}}</router-link></h4>
                                  

<span class="red">{{item.goods.shop_price}}</span><i>X</i>{{item.nums}}

<a title="" class="iconfont del" @click="deleteGoods(index,item.goods.id)"></a></dd> </dl>

goods.id is under goods_list.goods_ list. results [index]. Is there something wrong with your code?

Menu