浏览文章
文章信息
Postman 请求前修改请求体body
831
let order_products = JSON.parse(pm.environment.get("order_products"));for(let i=0;i<order_products.length;i++){let product = order_products[i];// if(product.shipped_quantity>0){// alert('该产品已发货!订单产品ID:'+product.order_product_id);// continue;// }// if(confirm('发货数量:1')){// product.shipped_quantity =1;// }product.shipped_quantity =1;order_products[i] = product;}pm.environment.set("ship_products", order_products);var data = JSON.parse(pm.request.body.raw);data.products = order_productslet body = {mode: 'raw',raw: JSON.stringify(data),options: {raw: {language: 'json'}}}pm.request.body.update(body)console.log(pm.request.body)