设置Golbals变量

打开postman — ADD
image.png

输入变量名和对应的初始值
image.png
设置完成之后 ,点击【保存】
可以看到已经保存到变量中
image.png

form中使用变量

image.png
image.png

使用变量的时候 使用 {{变量名}} 来引用变量。

表单中使用变量也是直接使用{{}} 来引用变量。
image.png

json数据中使用变量

image.png

  1. {
  2. "accesstoken":"{{token}}",
  3. "content":"哈哈哈哈哈哈哈"
  4. }

在json数据中也是使用 {{token}} 引用变量。

上下游传参

变量的使用-上下游传参 - 图8

  1. 接口之间有先后执行的顺序;
  2. 接口之间会有具体的数据字段进行关联 (一般情况下这个数据是唯一的)

上下游传参 主要就是指 两个或者两个以上的接口在测试的过程中,之间存在执行的先后顺序和关联;我们在处理这些接口的时候就要把这些接口关联起来。

相关名词:

  • 上下游关联
  • 参数关联
  • 报文关联(多接口中的报文是怎么处理的, 这里说的报文统称 请求的参数和服务器返回的数据)

上面这些都是同一个意思;

处理上下游关联

  1. 确定执行顺序;

下面以 发布话题—新建评论接口为例:

创建发布话题请求

还是原来的操作方式,根据文档做即可。
image.png

创建 新建评论接口

image.png
还是使用原来的方式来创建。

设置变量进行传参

每次发布话题都会产生新的topicid, 需要设置一个变量,每次产生新的id的时候 变量值能够自动更新。 动态设置变量。原来使用手工方式设置变量的值是固定的,已经不能满足当前的场景。

需要使用代码的方式来进行传参。

topicid 是在 创建话题上产生的,所以在创建话题上面写代码;
image.png
对应的代码。

  1. // 1. 获取服务器返回的结果 (固定通用的)
  2. var jsondata = pm.response.json();
  3. // 2. topic_id 值设置为 postman的全局变量 tid
  4. pm.globals.set("tid",jsondata.topic_id);

下游接口中引用变量
image.png

执行接口
【选择 save response】
image.png
可以看到执行的结果。
image.png

总结

上下游传参主要根据业务需求来做。
做法:

  1. 先确定上下游关系,确定执行顺序
  2. 在上游接口上设置变量。
  3. 下游接口中使用变量。

练习:

1. 新建主题

2. 编辑主题

3. 主题详情

变量的使用-上下游传参 - 图15

上下游关联.postman_collection.json
image.png

练习

前提条件:

  1. 设置两个token 变量 | token1 | 3de0a400-5289-49fa-8460-9270d91d5abb | | —- | —- | | token2 | 使用自己的token |

完成如下操作

  1. token1 用户 创建话题 — 创建话题请求
  2. token2 评论 token1 的话题 — 新建评论
  3. token1 回复 token2 的评论 — 新建评论
  4. token1 对token2 的评论点赞 — 为评论点赞
  5. token2 收藏了token1的话题 — 收藏话题接口

变量的使用-上下游传参 - 图17

  1. 创建两个token 变量

image.png

  1. 定义创建话题接口

image.png
设置变量传参
image.png
对应的代码

  1. var jsondata = pm.response.json();
  2. pm.globals.set('tid',jsondata.topic_id);
  1. 新建评论

image.png
将评论id设置为变量;
image.png

  1. var jsondata = pm.response.json();
  2. pm.globals.set('rid',jsondata.reply_id);
  1. 对评论进行回复

image.png

  1. 点赞评论

image.png

  1. 收藏话题

image.png

附件

上面对应的代码附件
参数关联.postman_collection.json
变量.postman_globals.json

为什么要使用上下游传参?

当在测试过程中,如果一个业务涉及到的接口特别多。手工一个一个测试也可以,就是当有关联的参数的时候,比如下订单,订单号每次都是唯一。不能对同一个订单进行重复支付。所以手工测试的话,就需要你手动的一个一个复制,对于测试效率很低。

使用上下游传参,可以显著的提高测试的效率。

复杂字段中提取变量

服务器返回结果的字段值特别多。

  1. {
  2. "success": true,
  3. "data": [
  4. {
  5. "id": "618cd940eabeee6b1ff2a613",
  6. "author_id": "6183dfee86e1a80501f642d2",
  7. "tab": "ask",
  8. "content": "<div class=\"markdown-text\"><p>慢慢不归</p>\n</div>",
  9. "title": "长路漫漫啊啊啊啊",
  10. "last_reply_at": "2021-11-11T08:50:08.756Z",
  11. "good": false,
  12. "top": false,
  13. "reply_count": 0,
  14. "visit_count": 0,
  15. "create_at": "2021-11-11T08:50:08.756Z",
  16. "author": {
  17. "loginname": "abtester",
  18. "avatar_url": "/public/images/userlogo.png"
  19. }
  20. },
  21. {
  22. "id": "618cd8b4eabeee6b1ff2a5cb",
  23. "author_id": "6183dfee86e1a80501f642d2",
  24. "tab": "share",
  25. "content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
  26. "title": "who are you",
  27. "last_reply_at": "2021-11-11T08:49:49.874Z",
  28. "good": false,
  29. "top": false,
  30. "reply_count": 13,
  31. "visit_count": 0,
  32. "create_at": "2021-11-11T08:47:48.572Z",
  33. "author": {
  34. "loginname": "abtester",
  35. "avatar_url": "/public/images/userlogo.png"
  36. }
  37. },
  38. {
  39. "id": "618cd924eabeee6b1ff2a610",
  40. "author_id": "6183dfee86e1a80501f642d2",
  41. "tab": "ask",
  42. "content": "<div class=\"markdown-text\"><p>枯藤老树昏鸦</p>\n</div>",
  43. "title": "浣溪沙。。。。。。",
  44. "last_reply_at": "2021-11-11T08:49:40.413Z",
  45. "good": false,
  46. "top": false,
  47. "reply_count": 0,
  48. "visit_count": 2,
  49. "create_at": "2021-11-11T08:49:40.413Z",
  50. "author": {
  51. "loginname": "abtester",
  52. "avatar_url": "/public/images/userlogo.png"
  53. }
  54. },
  55. {
  56. "id": "618cd91feabeee6b1ff2a60e",
  57. "author_id": "618b7453c34cab422241fbf4",
  58. "tab": "ask",
  59. "content": "<div class=\"markdown-text\"><p>hhhhhhashmdab</p>\n</div>",
  60. "title": "hedadadaaa",
  61. "last_reply_at": "2021-11-11T08:49:35.048Z",
  62. "good": false,
  63. "top": false,
  64. "reply_count": 0,
  65. "visit_count": 0,
  66. "create_at": "2021-11-11T08:49:35.048Z",
  67. "author": {
  68. "loginname": "heyong",
  69. "avatar_url": "/public/images/userlogo.png"
  70. }
  71. },
  72. {
  73. "id": "618cd90ceabeee6b1ff2a609",
  74. "author_id": "6183dfee86e1a80501f642d2",
  75. "tab": "ask",
  76. "content": "<div class=\"markdown-text\"><p>喵喵喵喵喵</p>\n</div>",
  77. "title": "一只笨猫呀",
  78. "last_reply_at": "2021-11-11T08:49:26.420Z",
  79. "good": false,
  80. "top": false,
  81. "reply_count": 2,
  82. "visit_count": 0,
  83. "create_at": "2021-11-11T08:49:16.993Z",
  84. "author": {
  85. "loginname": "abtester",
  86. "avatar_url": "/public/images/userlogo.png"
  87. }
  88. },
  89. {
  90. "id": "618cd8fdeabeee6b1ff2a600",
  91. "author_id": "6183dfee86e1a80501f642d2",
  92. "tab": "ask",
  93. "content": "<div class=\"markdown-text\"><p>波波最帅</p>\n</div>",
  94. "title": "史上最帅的我们111122221134",
  95. "last_reply_at": "2021-11-11T08:49:02.104Z",
  96. "good": false,
  97. "top": false,
  98. "reply_count": 2,
  99. "visit_count": 0,
  100. "create_at": "2021-11-11T08:49:01.914Z",
  101. "author": {
  102. "loginname": "abtester",
  103. "avatar_url": "/public/images/userlogo.png"
  104. }
  105. },
  106. {
  107. "id": "618cd8ebeabeee6b1ff2a5f2",
  108. "author_id": "618b74d0c34cab422241fbf8",
  109. "tab": "ask",
  110. "content": "<div class=\"markdown-text\"><p>hahahaaahaaaaa</p>\n</div>",
  111. "title": "五个胡乱哇",
  112. "last_reply_at": "2021-11-11T08:48:43.372Z",
  113. "good": false,
  114. "top": false,
  115. "reply_count": 2,
  116. "visit_count": 0,
  117. "create_at": "2021-11-11T08:48:43.168Z",
  118. "author": {
  119. "loginname": "wanghz",
  120. "avatar_url": "/public/images/userlogo.png"
  121. }
  122. },
  123. {
  124. "id": "618ccbc7eabeee6b1ff298a2",
  125. "author_id": "6183dfee86e1a80501f642d2",
  126. "tab": "ask",
  127. "content": "<div class=\"markdown-text\"><p>还是都很好</p>\n</div>",
  128. "title": "111111111111",
  129. "last_reply_at": "2021-11-11T08:48:41.810Z",
  130. "good": false,
  131. "top": false,
  132. "reply_count": 9,
  133. "visit_count": 6,
  134. "create_at": "2021-11-11T07:52:39.309Z",
  135. "author": {
  136. "loginname": "abtester",
  137. "avatar_url": "/public/images/userlogo.png"
  138. }
  139. },
  140. {
  141. "id": "618cd8d3eabeee6b1ff2a5e4",
  142. "author_id": "6183dfee86e1a80501f642d2",
  143. "tab": "ask",
  144. "content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
  145. "title": "立刻就辜负大家赶快来的",
  146. "last_reply_at": "2021-11-11T08:48:20.272Z",
  147. "good": false,
  148. "top": false,
  149. "reply_count": 2,
  150. "visit_count": 0,
  151. "create_at": "2021-11-11T08:48:19.971Z",
  152. "author": {
  153. "loginname": "abtester",
  154. "avatar_url": "/public/images/userlogo.png"
  155. }
  156. },
  157. {
  158. "id": "618ccce1eabeee6b1ff299c6",
  159. "author_id": "618b7291c34cab422241fbcb",
  160. "tab": "ask",
  161. "content": "<div class=\"markdown-text\"><p>健康成长</p>\n</div>",
  162. "title": "王嘉陆和陆依依",
  163. "last_reply_at": "2021-11-11T08:48:12.958Z",
  164. "good": false,
  165. "top": false,
  166. "reply_count": 5,
  167. "visit_count": 3,
  168. "create_at": "2021-11-11T07:57:21.724Z",
  169. "author": {
  170. "loginname": "wangyiqiu0822",
  171. "avatar_url": "/public/images/userlogo.png"
  172. }
  173. },
  174. {
  175. "id": "618cd8b7eabeee6b1ff2a5d0",
  176. "author_id": "6183dfee86e1a80501f642d2",
  177. "tab": "ask",
  178. "content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
  179. "title": "立刻就辜负大家赶快来的",
  180. "last_reply_at": "2021-11-11T08:48:02.832Z",
  181. "good": false,
  182. "top": false,
  183. "reply_count": 2,
  184. "visit_count": 0,
  185. "create_at": "2021-11-11T08:47:51.182Z",
  186. "author": {
  187. "loginname": "abtester",
  188. "avatar_url": "/public/images/userlogo.png"
  189. }
  190. },
  191. {
  192. "id": "618cd8b2eabeee6b1ff2a5c6",
  193. "author_id": "618b727ec34cab422241fbc3",
  194. "tab": "ask",
  195. "content": "<div class=\"markdown-text\"><p>哈哈哈哈哈哈哈哈</p>\n</div>",
  196. "title": "阿巴阿巴阿巴阿巴",
  197. "last_reply_at": "2021-11-11T08:47:47.208Z",
  198. "good": false,
  199. "top": false,
  200. "reply_count": 2,
  201. "visit_count": 0,
  202. "create_at": "2021-11-11T08:47:46.986Z",
  203. "author": {
  204. "loginname": "lilyy",
  205. "avatar_url": "/public/images/userlogo.png"
  206. }
  207. },
  208. {
  209. "id": "618cd846eabeee6b1ff2a57d",
  210. "author_id": "6183dfee86e1a80501f642d2",
  211. "tab": "share",
  212. "content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
  213. "title": "who are you",
  214. "last_reply_at": "2021-11-11T08:47:46.277Z",
  215. "good": false,
  216. "top": false,
  217. "reply_count": 1,
  218. "visit_count": 0,
  219. "create_at": "2021-11-11T08:45:58.929Z",
  220. "author": {
  221. "loginname": "abtester",
  222. "avatar_url": "/public/images/userlogo.png"
  223. }
  224. },
  225. {
  226. "id": "618cd8afeabeee6b1ff2a5be",
  227. "author_id": "618bcdf7eabeee6b1ff28184",
  228. "tab": "ask",
  229. "content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
  230. "title": "11112222",
  231. "last_reply_at": "2021-11-11T08:47:44.140Z",
  232. "good": false,
  233. "top": false,
  234. "reply_count": 1,
  235. "visit_count": 0,
  236. "create_at": "2021-11-11T08:47:43.927Z",
  237. "author": {
  238. "loginname": "test123",
  239. "avatar_url": "/public/images/userlogo.png"
  240. }
  241. },
  242. {
  243. "id": "618ccc96eabeee6b1ff29980",
  244. "author_id": "618bcdf7eabeee6b1ff28184",
  245. "tab": "ask",
  246. "content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
  247. "title": "11112222",
  248. "last_reply_at": "2021-11-11T08:47:44.035Z",
  249. "good": false,
  250. "top": false,
  251. "reply_count": 7,
  252. "visit_count": 0,
  253. "create_at": "2021-11-11T07:56:06.156Z",
  254. "author": {
  255. "loginname": "test123",
  256. "avatar_url": "/public/images/userlogo.png"
  257. }
  258. },
  259. {
  260. "id": "618cd8a6eabeee6b1ff2a5b7",
  261. "author_id": "6183dfee86e1a80501f642d2",
  262. "tab": "ask",
  263. "content": "<div class=\"markdown-text\"><p>在在在在在在</p>\n</div>",
  264. "title": "你好朋友哈哈哈",
  265. "last_reply_at": "2021-11-11T08:47:34.721Z",
  266. "good": false,
  267. "top": false,
  268. "reply_count": 2,
  269. "visit_count": 0,
  270. "create_at": "2021-11-11T08:47:34.496Z",
  271. "author": {
  272. "loginname": "abtester",
  273. "avatar_url": "/public/images/userlogo.png"
  274. }
  275. },
  276. {
  277. "id": "618cd89ceabeee6b1ff2a5b1",
  278. "author_id": "6183dfee86e1a80501f642d2",
  279. "tab": "ask",
  280. "content": "<div class=\"markdown-text\"><p>去去去去去去</p>\n</div>",
  281. "title": "213321346546879",
  282. "last_reply_at": "2021-11-11T08:47:24.347Z",
  283. "good": false,
  284. "top": false,
  285. "reply_count": 2,
  286. "visit_count": 0,
  287. "create_at": "2021-11-11T08:47:24.117Z",
  288. "author": {
  289. "loginname": "abtester",
  290. "avatar_url": "/public/images/userlogo.png"
  291. }
  292. },
  293. {
  294. "id": "618cd893eabeee6b1ff2a5ac",
  295. "author_id": "6183dfee86e1a80501f642d2",
  296. "tab": "ask",
  297. "content": "<div class=\"markdown-text\"><p>骑士归来之时</p>\n</div>",
  298. "title": "断剑重铸之日",
  299. "last_reply_at": "2021-11-11T08:47:15.361Z",
  300. "good": false,
  301. "top": false,
  302. "reply_count": 2,
  303. "visit_count": 0,
  304. "create_at": "2021-11-11T08:47:15.089Z",
  305. "author": {
  306. "loginname": "abtester",
  307. "avatar_url": "/public/images/userlogo.png"
  308. }
  309. },
  310. {
  311. "id": "618bb0baeabeee6b1ff27f59",
  312. "author_id": "6183dfee86e1a80501f642d2",
  313. "tab": "ask",
  314. "content": "<div class=\"markdown-text\"><p>跟我走一趟,我们掌握证据了</p>\n</div>",
  315. "title": "FBI,跟我走一趟,我们掌握了证据",
  316. "last_reply_at": "2021-11-11T08:47:02.209Z",
  317. "good": false,
  318. "top": false,
  319. "reply_count": 6,
  320. "visit_count": 0,
  321. "create_at": "2021-11-10T11:44:58.854Z",
  322. "author": {
  323. "loginname": "abtester",
  324. "avatar_url": "/public/images/userlogo.png"
  325. }
  326. },
  327. {
  328. "id": "618cd885eabeee6b1ff2a5a8",
  329. "author_id": "6183dfee86e1a80501f642d2",
  330. "tab": "ask",
  331. "content": "<div class=\"markdown-text\"><p>我想快点做好回家</p>\n</div>",
  332. "title": "hahahhahaha",
  333. "last_reply_at": "2021-11-11T08:47:01.907Z",
  334. "good": false,
  335. "top": false,
  336. "reply_count": 0,
  337. "visit_count": 0,
  338. "create_at": "2021-11-11T08:47:01.907Z",
  339. "author": {
  340. "loginname": "abtester",
  341. "avatar_url": "/public/images/userlogo.png"
  342. }
  343. }
  344. ]
  345. }
  1. var jsondata = pm.response.json();
  2. // 将第一个话题的id设置为变量 tid1 [0] 表示第一个数据
  3. pm.globals.set('tid1',jsondata.data[0].id);
  4. // 将第三个话题的 id 设置为变量 tid3
  5. pm.globals.set("tid3",jsondata.data[2].id);
  6. // 将第二个话题中 loginname 设置为变量 loginname2
  7. pm.globals.set('loginname2',jsondata.data[1].author.loginname);

image.png

如果服务器返回的结果为
打开postman中开发者选项
image.png

  1. var jsondata = {
  2. "name":"zhangsan",
  3. "age":20
  4. }

image.png

  1. var jsondata = {"name":"xiaoming", "friends": ["xiaohong","xiaohua","小张"]}

提取第一个朋友的名字

  1. jsondata.friends[0]

image.png

  1. var jsondata={"name":"xiaowang","concats":[
  2. {"name":"小小","phone":"11202203340"},
  3. {"name":"dada","phone":"22202203340"},
  4. {"name":"中中","phone":"33202203340"}
  5. ]}

第二个联系人的姓名

  1. jsondata.concats[1].name

第三个联系人的号码

  1. jsondata.concats[2].phone

  1. var jsondata = {
  2. "success": true,
  3. "data": [
  4. {
  5. "id": "618cd940eabeee6b1ff2a613",
  6. "author_id": "6183dfee86e1a80501f642d2",
  7. "tab": "ask",
  8. "content": "<div class=\"markdown-text\"><p>慢慢不归</p>\n</div>",
  9. "title": "长路漫漫啊啊啊啊",
  10. "last_reply_at": "2021-11-11T08:50:08.756Z",
  11. "good": false,
  12. "top": false,
  13. "reply_count": 0,
  14. "visit_count": 0,
  15. "create_at": "2021-11-11T08:50:08.756Z",
  16. "author": {
  17. "loginname": "abtester",
  18. "avatar_url": "/public/images/userlogo.png"
  19. }
  20. },
  21. {
  22. "id": "618cd8b4eabeee6b1ff2a5cb",
  23. "author_id": "6183dfee86e1a80501f642d2",
  24. "tab": "share",
  25. "content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
  26. "title": "who are you",
  27. "last_reply_at": "2021-11-11T08:49:49.874Z",
  28. "good": false,
  29. "top": false,
  30. "reply_count": 13,
  31. "visit_count": 0,
  32. "create_at": "2021-11-11T08:47:48.572Z",
  33. "author": {
  34. "loginname": "abtester",
  35. "avatar_url": "/public/images/userlogo.png"
  36. }
  37. },
  38. {
  39. "id": "618cd924eabeee6b1ff2a610",
  40. "author_id": "6183dfee86e1a80501f642d2",
  41. "tab": "ask",
  42. "content": "<div class=\"markdown-text\"><p>枯藤老树昏鸦</p>\n</div>",
  43. "title": "浣溪沙。。。。。。",
  44. "last_reply_at": "2021-11-11T08:49:40.413Z",
  45. "good": false,
  46. "top": false,
  47. "reply_count": 0,
  48. "visit_count": 2,
  49. "create_at": "2021-11-11T08:49:40.413Z",
  50. "author": {
  51. "loginname": "abtester",
  52. "avatar_url": "/public/images/userlogo.png"
  53. }
  54. },
  55. {
  56. "id": "618cd91feabeee6b1ff2a60e",
  57. "author_id": "618b7453c34cab422241fbf4",
  58. "tab": "ask",
  59. "content": "<div class=\"markdown-text\"><p>hhhhhhashmdab</p>\n</div>",
  60. "title": "hedadadaaa",
  61. "last_reply_at": "2021-11-11T08:49:35.048Z",
  62. "good": false,
  63. "top": false,
  64. "reply_count": 0,
  65. "visit_count": 0,
  66. "create_at": "2021-11-11T08:49:35.048Z",
  67. "author": {
  68. "loginname": "heyong",
  69. "avatar_url": "/public/images/userlogo.png"
  70. }
  71. },
  72. {
  73. "id": "618cd90ceabeee6b1ff2a609",
  74. "author_id": "6183dfee86e1a80501f642d2",
  75. "tab": "ask",
  76. "content": "<div class=\"markdown-text\"><p>喵喵喵喵喵</p>\n</div>",
  77. "title": "一只笨猫呀",
  78. "last_reply_at": "2021-11-11T08:49:26.420Z",
  79. "good": false,
  80. "top": false,
  81. "reply_count": 2,
  82. "visit_count": 0,
  83. "create_at": "2021-11-11T08:49:16.993Z",
  84. "author": {
  85. "loginname": "abtester",
  86. "avatar_url": "/public/images/userlogo.png"
  87. }
  88. },
  89. {
  90. "id": "618cd8fdeabeee6b1ff2a600",
  91. "author_id": "6183dfee86e1a80501f642d2",
  92. "tab": "ask",
  93. "content": "<div class=\"markdown-text\"><p>波波最帅</p>\n</div>",
  94. "title": "史上最帅的我们111122221134",
  95. "last_reply_at": "2021-11-11T08:49:02.104Z",
  96. "good": false,
  97. "top": false,
  98. "reply_count": 2,
  99. "visit_count": 0,
  100. "create_at": "2021-11-11T08:49:01.914Z",
  101. "author": {
  102. "loginname": "abtester",
  103. "avatar_url": "/public/images/userlogo.png"
  104. }
  105. },
  106. {
  107. "id": "618cd8ebeabeee6b1ff2a5f2",
  108. "author_id": "618b74d0c34cab422241fbf8",
  109. "tab": "ask",
  110. "content": "<div class=\"markdown-text\"><p>hahahaaahaaaaa</p>\n</div>",
  111. "title": "五个胡乱哇",
  112. "last_reply_at": "2021-11-11T08:48:43.372Z",
  113. "good": false,
  114. "top": false,
  115. "reply_count": 2,
  116. "visit_count": 0,
  117. "create_at": "2021-11-11T08:48:43.168Z",
  118. "author": {
  119. "loginname": "wanghz",
  120. "avatar_url": "/public/images/userlogo.png"
  121. }
  122. },
  123. {
  124. "id": "618ccbc7eabeee6b1ff298a2",
  125. "author_id": "6183dfee86e1a80501f642d2",
  126. "tab": "ask",
  127. "content": "<div class=\"markdown-text\"><p>还是都很好</p>\n</div>",
  128. "title": "111111111111",
  129. "last_reply_at": "2021-11-11T08:48:41.810Z",
  130. "good": false,
  131. "top": false,
  132. "reply_count": 9,
  133. "visit_count": 6,
  134. "create_at": "2021-11-11T07:52:39.309Z",
  135. "author": {
  136. "loginname": "abtester",
  137. "avatar_url": "/public/images/userlogo.png"
  138. }
  139. },
  140. {
  141. "id": "618cd8d3eabeee6b1ff2a5e4",
  142. "author_id": "6183dfee86e1a80501f642d2",
  143. "tab": "ask",
  144. "content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
  145. "title": "立刻就辜负大家赶快来的",
  146. "last_reply_at": "2021-11-11T08:48:20.272Z",
  147. "good": false,
  148. "top": false,
  149. "reply_count": 2,
  150. "visit_count": 0,
  151. "create_at": "2021-11-11T08:48:19.971Z",
  152. "author": {
  153. "loginname": "abtester",
  154. "avatar_url": "/public/images/userlogo.png"
  155. }
  156. },
  157. {
  158. "id": "618ccce1eabeee6b1ff299c6",
  159. "author_id": "618b7291c34cab422241fbcb",
  160. "tab": "ask",
  161. "content": "<div class=\"markdown-text\"><p>健康成长</p>\n</div>",
  162. "title": "王嘉陆和陆依依",
  163. "last_reply_at": "2021-11-11T08:48:12.958Z",
  164. "good": false,
  165. "top": false,
  166. "reply_count": 5,
  167. "visit_count": 3,
  168. "create_at": "2021-11-11T07:57:21.724Z",
  169. "author": {
  170. "loginname": "wangyiqiu0822",
  171. "avatar_url": "/public/images/userlogo.png"
  172. }
  173. },
  174. {
  175. "id": "618cd8b7eabeee6b1ff2a5d0",
  176. "author_id": "6183dfee86e1a80501f642d2",
  177. "tab": "ask",
  178. "content": "<div class=\"markdown-text\"><p>天气很好</p>\n</div>",
  179. "title": "立刻就辜负大家赶快来的",
  180. "last_reply_at": "2021-11-11T08:48:02.832Z",
  181. "good": false,
  182. "top": false,
  183. "reply_count": 2,
  184. "visit_count": 0,
  185. "create_at": "2021-11-11T08:47:51.182Z",
  186. "author": {
  187. "loginname": "abtester",
  188. "avatar_url": "/public/images/userlogo.png"
  189. }
  190. },
  191. {
  192. "id": "618cd8b2eabeee6b1ff2a5c6",
  193. "author_id": "618b727ec34cab422241fbc3",
  194. "tab": "ask",
  195. "content": "<div class=\"markdown-text\"><p>哈哈哈哈哈哈哈哈</p>\n</div>",
  196. "title": "阿巴阿巴阿巴阿巴",
  197. "last_reply_at": "2021-11-11T08:47:47.208Z",
  198. "good": false,
  199. "top": false,
  200. "reply_count": 2,
  201. "visit_count": 0,
  202. "create_at": "2021-11-11T08:47:46.986Z",
  203. "author": {
  204. "loginname": "lilyy",
  205. "avatar_url": "/public/images/userlogo.png"
  206. }
  207. },
  208. {
  209. "id": "618cd846eabeee6b1ff2a57d",
  210. "author_id": "6183dfee86e1a80501f642d2",
  211. "tab": "share",
  212. "content": "<div class=\"markdown-text\"><p>my name is lily,hi,everyone,I hone we are famliy</p>\n</div>",
  213. "title": "who are you",
  214. "last_reply_at": "2021-11-11T08:47:46.277Z",
  215. "good": false,
  216. "top": false,
  217. "reply_count": 1,
  218. "visit_count": 0,
  219. "create_at": "2021-11-11T08:45:58.929Z",
  220. "author": {
  221. "loginname": "abtester",
  222. "avatar_url": "/public/images/userlogo.png"
  223. }
  224. },
  225. {
  226. "id": "618cd8afeabeee6b1ff2a5be",
  227. "author_id": "618bcdf7eabeee6b1ff28184",
  228. "tab": "ask",
  229. "content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
  230. "title": "11112222",
  231. "last_reply_at": "2021-11-11T08:47:44.140Z",
  232. "good": false,
  233. "top": false,
  234. "reply_count": 1,
  235. "visit_count": 0,
  236. "create_at": "2021-11-11T08:47:43.927Z",
  237. "author": {
  238. "loginname": "test123",
  239. "avatar_url": "/public/images/userlogo.png"
  240. }
  241. },
  242. {
  243. "id": "618ccc96eabeee6b1ff29980",
  244. "author_id": "618bcdf7eabeee6b1ff28184",
  245. "tab": "ask",
  246. "content": "<div class=\"markdown-text\"><p>好好好</p>\n</div>",
  247. "title": "11112222",
  248. "last_reply_at": "2021-11-11T08:47:44.035Z",
  249. "good": false,
  250. "top": false,
  251. "reply_count": 7,
  252. "visit_count": 0,
  253. "create_at": "2021-11-11T07:56:06.156Z",
  254. "author": {
  255. "loginname": "test123",
  256. "avatar_url": "/public/images/userlogo.png"
  257. }
  258. },
  259. {
  260. "id": "618cd8a6eabeee6b1ff2a5b7",
  261. "author_id": "6183dfee86e1a80501f642d2",
  262. "tab": "ask",
  263. "content": "<div class=\"markdown-text\"><p>在在在在在在</p>\n</div>",
  264. "title": "你好朋友哈哈哈",
  265. "last_reply_at": "2021-11-11T08:47:34.721Z",
  266. "good": false,
  267. "top": false,
  268. "reply_count": 2,
  269. "visit_count": 0,
  270. "create_at": "2021-11-11T08:47:34.496Z",
  271. "author": {
  272. "loginname": "abtester",
  273. "avatar_url": "/public/images/userlogo.png"
  274. }
  275. },
  276. {
  277. "id": "618cd89ceabeee6b1ff2a5b1",
  278. "author_id": "6183dfee86e1a80501f642d2",
  279. "tab": "ask",
  280. "content": "<div class=\"markdown-text\"><p>去去去去去去</p>\n</div>",
  281. "title": "213321346546879",
  282. "last_reply_at": "2021-11-11T08:47:24.347Z",
  283. "good": false,
  284. "top": false,
  285. "reply_count": 2,
  286. "visit_count": 0,
  287. "create_at": "2021-11-11T08:47:24.117Z",
  288. "author": {
  289. "loginname": "abtester",
  290. "avatar_url": "/public/images/userlogo.png"
  291. }
  292. },
  293. {
  294. "id": "618cd893eabeee6b1ff2a5ac",
  295. "author_id": "6183dfee86e1a80501f642d2",
  296. "tab": "ask",
  297. "content": "<div class=\"markdown-text\"><p>骑士归来之时</p>\n</div>",
  298. "title": "断剑重铸之日",
  299. "last_reply_at": "2021-11-11T08:47:15.361Z",
  300. "good": false,
  301. "top": false,
  302. "reply_count": 2,
  303. "visit_count": 0,
  304. "create_at": "2021-11-11T08:47:15.089Z",
  305. "author": {
  306. "loginname": "abtester",
  307. "avatar_url": "/public/images/userlogo.png"
  308. }
  309. },
  310. {
  311. "id": "618bb0baeabeee6b1ff27f59",
  312. "author_id": "6183dfee86e1a80501f642d2",
  313. "tab": "ask",
  314. "content": "<div class=\"markdown-text\"><p>跟我走一趟,我们掌握证据了</p>\n</div>",
  315. "title": "FBI,跟我走一趟,我们掌握了证据",
  316. "last_reply_at": "2021-11-11T08:47:02.209Z",
  317. "good": false,
  318. "top": false,
  319. "reply_count": 6,
  320. "visit_count": 0,
  321. "create_at": "2021-11-10T11:44:58.854Z",
  322. "author": {
  323. "loginname": "abtester",
  324. "avatar_url": "/public/images/userlogo.png"
  325. }
  326. },
  327. {
  328. "id": "618cd885eabeee6b1ff2a5a8",
  329. "author_id": "6183dfee86e1a80501f642d2",
  330. "tab": "ask",
  331. "content": "<div class=\"markdown-text\"><p>我想快点做好回家</p>\n</div>",
  332. "title": "hahahhahaha",
  333. "last_reply_at": "2021-11-11T08:47:01.907Z",
  334. "good": false,
  335. "top": false,
  336. "reply_count": 0,
  337. "visit_count": 0,
  338. "create_at": "2021-11-11T08:47:01.907Z",
  339. "author": {
  340. "loginname": "abtester",
  341. "avatar_url": "/public/images/userlogo.png"
  342. }
  343. }
  344. ]
  345. }
  1. 第3个话题的title

    1. jsondata.data[2].title
  2. 第10个话题的 loginname

    1. jsondata.data[9].author.loginname

作业

  1. 10个常见的http状态码
  2. cnode社区 接口上游传参 练习
    1. token1 发布一个话题 — 新建主题
    2. token2 回复token1 发布的话题 — 新建评论
    3. token1 获取未读消息和已读消息 — 获取未读消息和已读消息 (备注 从 hasnot_read_messages 中获取第一个未读消息id 设置变量)
    4. token1 标记单个消息为已读 — 标记单个消息为已读