当前位置:网站首页>apipost脚本使用讲解一~全局变量
apipost脚本使用讲解一~全局变量
2022-06-27 21:06:00 【sik1】
一、全局变量 设置一个全局变量:apt.globals.set("key", "value"); 可以用apt.globals.set()设置一个自定义的值,如:apt.globals.set("test", "这是一个全局变量"); apt.globals.set()方法可以和request方法、response方法一起使用。 apt.globals.set()和request方法一起使用可以获取当前的请求:如 apt.globals.set("request", request);获取当前的请求详情 apt.globals.set("url", request.url);获取当前请求的url apt.globals.set("method", request.method);获取当前请求的method apt.globals.set("timeout", request.timeout);获取当前请求超时时间 apt.globals.set("contentType", request.contentType);获取当前请求的content-type apt.globals.set("bodys", request.request_bodys);获取当前的请求体 apt.globals.set("headers", request.request_headers);获取当前的请求头 apt.globals.set("querys", request.request_querys);获取当前请求的querys apt.globals.set()和response方法一起使用可以获取当前的响应:如 apt.globals.set("response", response);获取当前请求的响应 apt.globals.set("json", response.json);响应为json的时候,获取json格式的响应数据 apt.globals.set("headers", response.headers);获取当前的响应头 apt.globals.set("cookies", response.cookies);获取当前请求的响应cookie apt.globals.set("raw", response.raw);获取原始响应数据 apt.globals.set("status", response.raw.status);获取当前响应状态码(200、301、400等) apt.globals.set("responseTime", response.raw.responseTime);获取当前响应时间(毫秒) apt.globals.set("type", response.raw.type);获取当前响应类型(json等) apt.globals.set("responseText", response.raw.responseText);获取当前响应文本 Apipost官方链接:https://console.apipost.cn/register?utm_source=10008
边栏推荐
- Fsnotify interface of go language to monitor file modification
- Online JSON to plaintext tool
- 上手了一个自然语言模型BLOOM
- Netease cloud lost its "feelings" card
- 手把手教你移植 tinyriscv 到FPGA上
- Windows环境下的ELK——Logstash+Mysql(4)
- [electron] 基础学习
- Feign implements path escape through custom annotations
- 居家办公竟比去公司上班还累?
- How vivado adds timing constraints
猜你喜欢

C# Winform 读取Resources图片

MySQL十八:写语句的执行过程

Design of STM32 and rc522 simple bus card system

webserver流程图——搞懂webserver各模块间调用关系

【PCL自学:Segmentation3】基于PCL的点云分割:区域增长分割

因美纳陷数据泄露“丑闻”:我国基因数据安全能交给美企吗?

Discuz小鱼游戏风影传说商业GBK+UTF8版模板/DZ游戏网站模板

Ice cream or snow "high"?

Golang - the difference between new and make

未能加载文件或程序集“CefSharp.Core.Runtime.dll”或它的某一个依赖项。 不是有效的 Win32 应用程序。 (异常来自 HRESULT:0x800700C1)
随机推荐
Web worker introduction and use cases
Teach you how to transplant tinyriscv to FPGA
webService
Google Earth engine (GEE) 03 vector data type
浙江大学课程攻略共享计划
【IDEA】IDEA 格式化 代码技巧 idea 格式化 会加 <p> 标签
Golang - the difference between new and make
小芯片chiplet技术杂谈
官宣!Apache Doris 从 Apache 孵化器毕业,正式成为 Apache 顶级项目!
思源笔记订阅停止直接删云端数据嘛?
如何找到外文文献对应的中文文献?
c语言之字符串数组
【AI应用】NVIDIA GeForce RTX 3060的详情参数
Download versions such as typora 1.2.5
MySQL删除表后如何使ID从1开始
vmware虚拟机桥接连通
Usage of vivado vio IP
Working at home is more tiring than going to work at the company?
2022年PMP项目管理考试敏捷知识点(3)
刚开始看英文文献,想问一下各位,最初应该怎么看进去?