以社区为例:
社区层级划分有5个层次:社区->组团->楼栋->单元->房间 依次的type值为:1,2,3,4,5
需要提取某一个层级的房间id作为后续接口调用。房间id通过层级的层层递进方可取到,以下按三个层级来举例:社区->楼栋->房间 具体的提取方法如下:
// 先提取出环境变量中的user_token
var user_token = pm.environment.get("user_token");
//构建get请求,获取该登录用户下的所有社区
var base_url = "我的接口地址";
var get_url = base_url + "id=0" + "&type=0"; // 拼接参数(id,type) 值0:代表获取社区列表
const GetCommunityRequest = {
url: get_url,
method: "GET",
header: {
authorization: "Bearer " + user_token
}
};
// 执行请求,提取第一个社区的id,和type值,并设置为环境变量
pm.sendRequest(GetCommunityRequest, function (err, response) {
var data = response.json()
pm.environment.set("community_id", data.item[0].id)
pm.environment.set("community_type", data.item[0