What should I do if the data at the front end of the vue, is inconsistent with the data required by the background?

clipboard.png

now make a drop-down multi-selection, as shown in the figure, and the selected id is [2prime3]

.

but the background requires the data to be like this:

[
    {
        "appId":2,
        "direction":"1"
    },                    
    {
        "appId":3,
        "direction":"1"
    },
]

where direction is always dead for 1, how can I change it to the format I want at the back end?


var data= [2hr class= 3] .map (r = > {return {'appid':r,'direction':'1'}}); console.log (data)


function handleData(data) {
  let _data = data.map(item => {
    return {
      'appid': item,
      'direction': '1'
    }
  })
  return _data;
}

js to construct the array needed by the backend, foreach the array you get from the drop-down list (for example), put {appId:foreachItem,direction:1} in an array variable at a time, and finally pass the array to the backend

.
Menu