使用runapi发起多次请求发送多条json数据的时候数据没有变化,runapi又没有多少能找到的脚本可用,这里就记录一下自己简单使用的基础代码。
先上代码
//post请求body中的json {"name":"fengxinzi","age":12, "tel":"13666666666", "user":"useraccount"}
//get请求同理 用到这个函数runapi.setParam("timestamp2",timestamp2),自行修改
var json = runapi.getParamJson()
json.user= Math.random().toString(36).slice(-8)
var nuM = [];
for (var i = 0; i < 11; i++) {
var num = Math.floor(Math.random() * 10);
nuM.unshift(num);
}
json.tel=nuM.toString().replaceAll(",", "")
runapi.setParamJson(json)
首先要在body里写入json数据
{ "name": "案例名456789", "icon": "6fc1de65cd8d8b3bf92518687c39be02.png" }
然后切换到前执行脚本,获取body中的json数据
var json = runapi.getParamJson()
查看一下获取到的数据
runapi.alert(json)
为属性赋值,这里使用随机字符串,并查看,name的值以改变
json.name = Math.random().toString(36).slice(-8)
runapi.alert(json)
最后再将改好的json数据设置到json请求参数中
runapi.setParamJson(json)
请求就会拿着最新的json发起请求