设置Golbals变量
打开postman — ADD
输入变量名和对应的初始值
设置完成之后 ,点击【保存】
可以看到已经保存到变量中
form中使用变量
使用变量的时候 使用 {{变量名}}
来引用变量。
表单中使用变量也是直接使用{{}}
来引用变量。
json数据中使用变量
{
"accesstoken":"{{token}}",
"content":"哈哈哈哈哈哈哈"
}
在json数据中也是使用 {{token}}
引用变量。
上下游传参
- 接口之间有先后执行的顺序;
- 接口之间会有具体的数据字段进行关联 (一般情况下这个数据是唯一的)
上下游传参 主要就是指 两个或者两个以上的接口在测试的过程中,之间存在执行的先后顺序和关联;我们在处理这些接口的时候就要把这些接口关联起来。
相关名词:
- 上下游关联
- 参数关联
- 报文关联(多接口中的报文是怎么处理的, 这里说的报文统称 请求的参数和服务器返回的数据)
上面这些都是同一个意思;
处理上下游关联
- 确定执行顺序;
创建发布话题请求
还是原来的操作方式,根据文档做即可。
创建 新建评论接口
设置变量进行传参
每次发布话题都会产生新的topicid, 需要设置一个变量,每次产生新的id的时候 变量值能够自动更新。 动态设置变量。原来使用手工方式设置变量的值是固定的,已经不能满足当前的场景。
需要使用代码的方式来进行传参。
topicid 是在 创建话题上产生的,所以在创建话题上面写代码;
对应的代码。
// 1. 获取服务器返回的结果 (固定通用的)
var jsondata = pm.response.json();
// 2. 将topic_id 值设置为 postman的全局变量 tid
pm.globals.set("tid",jsondata.topic_id);
下游接口中引用变量
执行接口
【选择 save response】
可以看到执行的结果。
总结
上下游传参主要根据业务需求来做。
做法:
- 先确定上下游关系,确定执行顺序
- 在上游接口上设置变量。
- 下游接口中使用变量。
练习:
1. 新建主题
2. 编辑主题
3. 主题详情
练习
前提条件:
- 设置两个token 变量 | token1 | 3de0a400-5289-49fa-8460-9270d91d5abb | | —- | —- | | token2 | 使用自己的token |
完成如下操作
- token1 用户 创建话题 — 创建话题请求
- token2 评论 token1 的话题 — 新建评论
- token1 回复 token2 的评论 — 新建评论
- token1 对token2 的评论点赞 — 为评论点赞
- token2 收藏了token1的话题 — 收藏话题接口
- 创建两个token 变量
- 定义创建话题接口
设置变量传参
对应的代码
var jsondata = pm.response.json();
pm.globals.set('tid',jsondata.topic_id);
- 新建评论
将评论id设置为变量;
var jsondata = pm.response.json();
pm.globals.set('rid',jsondata.reply_id);
- 对评论进行回复
- 点赞评论
- 收藏话题
附件
上面对应的代码附件
参数关联.postman_collection.json
变量.postman_globals.json
为什么要使用上下游传参?
当在测试过程中,如果一个业务涉及到的接口特别多。手工一个一个测试也可以,就是当有关联的参数的时候,比如下订单,订单号每次都是唯一。不能对同一个订单进行重复支付。所以手工测试的话,就需要你手动的一个一个复制,对于测试效率很低。
使用上下游传参,可以显著的提高测试的效率。
复杂字段中提取变量
服务器返回结果的字段值特别多。
{
"success": true,
"data": [
{
"id": "618cd940eabeee6b1ff2a613",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>慢慢不归</p>\n</div>",
"title": "长路漫漫啊啊啊啊",
"last_reply_at": "2021-11-11T08:50:08.756Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-11-11T08:50:08.756Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8b4eabeee6b1ff2a5cb",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
"title": "who are you",
"last_reply_at": "2021-11-11T08:49:49.874Z",
"good": false,
"top": false,
"reply_count": 13,
"visit_count": 0,
"create_at": "2021-11-11T08:47:48.572Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd924eabeee6b1ff2a610",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>枯藤老树昏鸦</p>\n</div>",
"title": "浣溪沙。。。。。。",
"last_reply_at": "2021-11-11T08:49:40.413Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 2,
"create_at": "2021-11-11T08:49:40.413Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd91feabeee6b1ff2a60e",
"author_id": "618b7453c34cab422241fbf4",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>hhhhhhashmdab</p>\n</div>",
"title": "hedadadaaa",
"last_reply_at": "2021-11-11T08:49:35.048Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-11-11T08:49:35.048Z",
"author": {
"loginname": "heyong",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd90ceabeee6b1ff2a609",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>喵喵喵喵喵</p>\n</div>",
"title": "一只笨猫呀",
"last_reply_at": "2021-11-11T08:49:26.420Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:49:16.993Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8fdeabeee6b1ff2a600",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>波波最帅</p>\n</div>",
"title": "史上最帅的我们111122221134",
"last_reply_at": "2021-11-11T08:49:02.104Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:49:01.914Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8ebeabeee6b1ff2a5f2",
"author_id": "618b74d0c34cab422241fbf8",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>hahahaaahaaaaa</p>\n</div>",
"title": "五个胡乱哇",
"last_reply_at": "2021-11-11T08:48:43.372Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:48:43.168Z",
"author": {
"loginname": "wanghz",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618ccbc7eabeee6b1ff298a2",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>还是都很好</p>\n</div>",
"title": "111111111111",
"last_reply_at": "2021-11-11T08:48:41.810Z",
"good": false,
"top": false,
"reply_count": 9,
"visit_count": 6,
"create_at": "2021-11-11T07:52:39.309Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8d3eabeee6b1ff2a5e4",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
"title": "立刻就辜负大家赶快来的",
"last_reply_at": "2021-11-11T08:48:20.272Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:48:19.971Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618ccce1eabeee6b1ff299c6",
"author_id": "618b7291c34cab422241fbcb",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>健康成长</p>\n</div>",
"title": "王嘉陆和陆依依",
"last_reply_at": "2021-11-11T08:48:12.958Z",
"good": false,
"top": false,
"reply_count": 5,
"visit_count": 3,
"create_at": "2021-11-11T07:57:21.724Z",
"author": {
"loginname": "wangyiqiu0822",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8b7eabeee6b1ff2a5d0",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
"title": "立刻就辜负大家赶快来的",
"last_reply_at": "2021-11-11T08:48:02.832Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:51.182Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8b2eabeee6b1ff2a5c6",
"author_id": "618b727ec34cab422241fbc3",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>哈哈哈哈哈哈哈哈</p>\n</div>",
"title": "阿巴阿巴阿巴阿巴",
"last_reply_at": "2021-11-11T08:47:47.208Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:46.986Z",
"author": {
"loginname": "lilyy",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd846eabeee6b1ff2a57d",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
"title": "who are you",
"last_reply_at": "2021-11-11T08:47:46.277Z",
"good": false,
"top": false,
"reply_count": 1,
"visit_count": 0,
"create_at": "2021-11-11T08:45:58.929Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8afeabeee6b1ff2a5be",
"author_id": "618bcdf7eabeee6b1ff28184",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
"title": "11112222",
"last_reply_at": "2021-11-11T08:47:44.140Z",
"good": false,
"top": false,
"reply_count": 1,
"visit_count": 0,
"create_at": "2021-11-11T08:47:43.927Z",
"author": {
"loginname": "test123",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618ccc96eabeee6b1ff29980",
"author_id": "618bcdf7eabeee6b1ff28184",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
"title": "11112222",
"last_reply_at": "2021-11-11T08:47:44.035Z",
"good": false,
"top": false,
"reply_count": 7,
"visit_count": 0,
"create_at": "2021-11-11T07:56:06.156Z",
"author": {
"loginname": "test123",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8a6eabeee6b1ff2a5b7",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>在在在在在在</p>\n</div>",
"title": "你好朋友哈哈哈",
"last_reply_at": "2021-11-11T08:47:34.721Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:34.496Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd89ceabeee6b1ff2a5b1",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>去去去去去去</p>\n</div>",
"title": "213321346546879",
"last_reply_at": "2021-11-11T08:47:24.347Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:24.117Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd893eabeee6b1ff2a5ac",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>骑士归来之时</p>\n</div>",
"title": "断剑重铸之日",
"last_reply_at": "2021-11-11T08:47:15.361Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:15.089Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618bb0baeabeee6b1ff27f59",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>跟我走一趟,我们掌握证据了</p>\n</div>",
"title": "FBI,跟我走一趟,我们掌握了证据",
"last_reply_at": "2021-11-11T08:47:02.209Z",
"good": false,
"top": false,
"reply_count": 6,
"visit_count": 0,
"create_at": "2021-11-10T11:44:58.854Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd885eabeee6b1ff2a5a8",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>我想快点做好回家</p>\n</div>",
"title": "hahahhahaha",
"last_reply_at": "2021-11-11T08:47:01.907Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-11-11T08:47:01.907Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
}
]
}
var jsondata = pm.response.json();
// 将第一个话题的id设置为变量 tid1 [0] 表示第一个数据
pm.globals.set('tid1',jsondata.data[0].id);
// 将第三个话题的 id 设置为变量 tid3
pm.globals.set("tid3",jsondata.data[2].id);
// 将第二个话题中 loginname 设置为变量 loginname2
pm.globals.set('loginname2',jsondata.data[1].author.loginname);
如果服务器返回的结果为
打开postman中开发者选项
var jsondata = {
"name":"zhangsan",
"age":20
}
var jsondata = {"name":"xiaoming", "friends": ["xiaohong","xiaohua","小张"]}
提取第一个朋友的名字
jsondata.friends[0]
var jsondata={"name":"xiaowang","concats":[
{"name":"小小","phone":"11202203340"},
{"name":"dada","phone":"22202203340"},
{"name":"中中","phone":"33202203340"}
]}
第二个联系人的姓名
jsondata.concats[1].name
第三个联系人的号码
jsondata.concats[2].phone
var jsondata = {
"success": true,
"data": [
{
"id": "618cd940eabeee6b1ff2a613",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>慢慢不归</p>\n</div>",
"title": "长路漫漫啊啊啊啊",
"last_reply_at": "2021-11-11T08:50:08.756Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-11-11T08:50:08.756Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8b4eabeee6b1ff2a5cb",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
"title": "who are you",
"last_reply_at": "2021-11-11T08:49:49.874Z",
"good": false,
"top": false,
"reply_count": 13,
"visit_count": 0,
"create_at": "2021-11-11T08:47:48.572Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd924eabeee6b1ff2a610",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>枯藤老树昏鸦</p>\n</div>",
"title": "浣溪沙。。。。。。",
"last_reply_at": "2021-11-11T08:49:40.413Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 2,
"create_at": "2021-11-11T08:49:40.413Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd91feabeee6b1ff2a60e",
"author_id": "618b7453c34cab422241fbf4",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>hhhhhhashmdab</p>\n</div>",
"title": "hedadadaaa",
"last_reply_at": "2021-11-11T08:49:35.048Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-11-11T08:49:35.048Z",
"author": {
"loginname": "heyong",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd90ceabeee6b1ff2a609",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>喵喵喵喵喵</p>\n</div>",
"title": "一只笨猫呀",
"last_reply_at": "2021-11-11T08:49:26.420Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:49:16.993Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8fdeabeee6b1ff2a600",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>波波最帅</p>\n</div>",
"title": "史上最帅的我们111122221134",
"last_reply_at": "2021-11-11T08:49:02.104Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:49:01.914Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8ebeabeee6b1ff2a5f2",
"author_id": "618b74d0c34cab422241fbf8",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>hahahaaahaaaaa</p>\n</div>",
"title": "五个胡乱哇",
"last_reply_at": "2021-11-11T08:48:43.372Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:48:43.168Z",
"author": {
"loginname": "wanghz",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618ccbc7eabeee6b1ff298a2",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>还是都很好</p>\n</div>",
"title": "111111111111",
"last_reply_at": "2021-11-11T08:48:41.810Z",
"good": false,
"top": false,
"reply_count": 9,
"visit_count": 6,
"create_at": "2021-11-11T07:52:39.309Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8d3eabeee6b1ff2a5e4",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
"title": "立刻就辜负大家赶快来的",
"last_reply_at": "2021-11-11T08:48:20.272Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:48:19.971Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618ccce1eabeee6b1ff299c6",
"author_id": "618b7291c34cab422241fbcb",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>健康成长</p>\n</div>",
"title": "王嘉陆和陆依依",
"last_reply_at": "2021-11-11T08:48:12.958Z",
"good": false,
"top": false,
"reply_count": 5,
"visit_count": 3,
"create_at": "2021-11-11T07:57:21.724Z",
"author": {
"loginname": "wangyiqiu0822",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8b7eabeee6b1ff2a5d0",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
"title": "立刻就辜负大家赶快来的",
"last_reply_at": "2021-11-11T08:48:02.832Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:51.182Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8b2eabeee6b1ff2a5c6",
"author_id": "618b727ec34cab422241fbc3",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>哈哈哈哈哈哈哈哈</p>\n</div>",
"title": "阿巴阿巴阿巴阿巴",
"last_reply_at": "2021-11-11T08:47:47.208Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:46.986Z",
"author": {
"loginname": "lilyy",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd846eabeee6b1ff2a57d",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "share",
"content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
"title": "who are you",
"last_reply_at": "2021-11-11T08:47:46.277Z",
"good": false,
"top": false,
"reply_count": 1,
"visit_count": 0,
"create_at": "2021-11-11T08:45:58.929Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8afeabeee6b1ff2a5be",
"author_id": "618bcdf7eabeee6b1ff28184",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
"title": "11112222",
"last_reply_at": "2021-11-11T08:47:44.140Z",
"good": false,
"top": false,
"reply_count": 1,
"visit_count": 0,
"create_at": "2021-11-11T08:47:43.927Z",
"author": {
"loginname": "test123",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618ccc96eabeee6b1ff29980",
"author_id": "618bcdf7eabeee6b1ff28184",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
"title": "11112222",
"last_reply_at": "2021-11-11T08:47:44.035Z",
"good": false,
"top": false,
"reply_count": 7,
"visit_count": 0,
"create_at": "2021-11-11T07:56:06.156Z",
"author": {
"loginname": "test123",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd8a6eabeee6b1ff2a5b7",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>在在在在在在</p>\n</div>",
"title": "你好朋友哈哈哈",
"last_reply_at": "2021-11-11T08:47:34.721Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:34.496Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd89ceabeee6b1ff2a5b1",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>去去去去去去</p>\n</div>",
"title": "213321346546879",
"last_reply_at": "2021-11-11T08:47:24.347Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:24.117Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd893eabeee6b1ff2a5ac",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>骑士归来之时</p>\n</div>",
"title": "断剑重铸之日",
"last_reply_at": "2021-11-11T08:47:15.361Z",
"good": false,
"top": false,
"reply_count": 2,
"visit_count": 0,
"create_at": "2021-11-11T08:47:15.089Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618bb0baeabeee6b1ff27f59",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>跟我走一趟,我们掌握证据了</p>\n</div>",
"title": "FBI,跟我走一趟,我们掌握了证据",
"last_reply_at": "2021-11-11T08:47:02.209Z",
"good": false,
"top": false,
"reply_count": 6,
"visit_count": 0,
"create_at": "2021-11-10T11:44:58.854Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
},
{
"id": "618cd885eabeee6b1ff2a5a8",
"author_id": "6183dfee86e1a80501f642d2",
"tab": "ask",
"content": "<div class=\"markdown-text\"><p>我想快点做好回家</p>\n</div>",
"title": "hahahhahaha",
"last_reply_at": "2021-11-11T08:47:01.907Z",
"good": false,
"top": false,
"reply_count": 0,
"visit_count": 0,
"create_at": "2021-11-11T08:47:01.907Z",
"author": {
"loginname": "abtester",
"avatar_url": "/public/images/userlogo.png"
}
}
]
}
第3个话题的title
jsondata.data[2].title
第10个话题的 loginname
jsondata.data[9].author.loginname
作业
- 10个常见的http状态码
- cnode社区 接口上游传参 练习
- token1 发布一个话题 — 新建主题
- token2 回复token1 发布的话题 — 新建评论
- token1 获取未读消息和已读消息 — 获取未读消息和已读消息 (备注 从 hasnot_read_messages 中获取第一个未读消息id 设置变量)
- token1 标记单个消息为已读 — 标记单个消息为已读