实用工具

HttpGet

发送 GET 请求并返回响应正文。

语法

HttpGet(context: any, url: string, cache?: boolean | number): string

参数

名称类型描述
contextany调用方法样式帮助器时提供的自身或上下文参数。
urlstring要连接的 HTTP 或 WebSocket URL。
cache?boolean | number启用或禁用此行为的布尔选项。

返回值

名称类型描述
bodystringHTTP 响应正文。

说明

发送 GET 请求并返回响应正文。

使用 3 个参数调用: context, url, cache。参数表会说明哪些值必填,哪些值只用于细化行为。

返回 body (string)。使用返回表区分成功值、nil 结果和可恢复错误。

示例

使用占位值的示例调用。

local result = HttpGet(nil, "example", true)
print(result)