Reading the data in the same cycle returns the result set to the variable

Scene Description:

Delete (empty) shopping cart interface need to pass each of the acquired product data

 

 

 

 

Here there is a problem, the shopping cart is not known how much data, check out the results are displayed in the format below

 

 

 

 

So, to return data queries cart, cyclic read and write array, set to global variables

 

Then, remove the interface writes the unknown variable realize cart delete data

 

 

 

 

(Query interfaces cart return data)

 

 

 

(Query cart interface returns data processing, and the id written to the array, set the global variable )

 

 

 

(Delete reference variable structure)

 

 

 

response=JSON.parse(response);

let deleteID=[];

for(var i =0;i<response.Data.OnSaleList.length;i++){

        var item=response.Data.OnSaleList[i];

        deleteID.push (item.Id); // where id refers to an array of data needs to be written, the data is passed to other interfaces needed

 }

 env.globalParams [ "deleteID"] = JSON.stringify (deleteID); // because the interface is deleted RAW format, here to json technology, if you do not need to be written as " env.globalParams [" deleteID "] = deleteID; "

Guess you like

Origin www.cnblogs.com/becks/p/12508818.html