You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Thunder Client脚本开发:如何获取当前运行请求的URL?

在Thunder Client中获取当前请求URL的方法

Thunder Client 提供了与 Postman pm 对应的全局对象 tc,你可以通过它获取当前运行请求的 URL,用法和 Postman 的 pm.request.url 非常相似:

  • 获取完整的 URL 字符串:tc.request.url
  • 若需要拆分 URL 的具体组成部分,可访问以下属性:
    • 协议:tc.request.url.protocol
    • 主机:tc.request.url.host
    • 路径:tc.request.url.path
    • 查询参数:tc.request.url.query

示例代码(可在 Pre-request Script 或 Test Script 中使用):

// 打印完整请求URL
console.log("当前请求URL:", tc.request.url);

// 提取并打印主机部分
console.log("请求主机地址:", tc.request.url.host);

这个 API 完全能满足你脚本开发中获取当前请求 URL 的需求。

内容的提问来源于stack exchange,提问作者Niner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 12:34:50