How to get the corresponding data in the shopping cart

my general idea is like this, but it always feels wrong. Help me take a look.

first add a set of data to the list array while clicking add to the shopping cart, as follows:

list:[{id:123,count:1},{id:456,count:2}]

then loop through the list array in the shopping cart to get id and count.
and send an axios request, compare the id with the background data, get the data (object) and use vue.set to add the field "count" to the data and assign a value.
ends up with a piece of data corresponding to list.

but doing so will cause the number of axios requests sent to be equal to the length of the list array.

is mainly about how to solve the problem of number of requests and count field.

Apr.15,2022

allows the backend to provide an interface. The parameter required by the interface is a collection of id, and then returns an array set like list

.
Menu