Documentation

requests.do() 函数

requests.do() 是实验性的,随时可能会更改。

requests.do() 发起一个http请求。

已弃用

实验性 requests.do 已被弃用,建议使用 requests.do。

返回的响应包含以下属性:

  • statusCode: 从请求返回的HTTP状态码。
  • body: 请求的内容。最多将从响应主体读取100MB的大小。
  • headers: 响应中存在的头部。
  • 持续时间:请求的持续时间。
函数类型签名
(
    method: string,
    url: string,
    ?body: bytes,
    ?config: {A with timeout: duration, insecureSkipVerify: bool},
    ?headers: [string:string],
    ?params: [string:[string]],
) => {statusCode: int, headers: [string:string], duration: duration, body: bytes}

有关更多信息,请参见 Function type signatures。

参数

方法

(必需) http请求的方法。 支持的方法:DELETE, GET, HEAD, PATCH, POST, PUT。

网址

(必填) 请求的URL。这里不应该包括任何查询参数。

参数

要添加到URL作为查询参数的一组键值对。 查询参数将被URL编码。 与一个键相关的所有值将附加到查询中。

头部信息

请求中要包含的键值对集合。

主体

要随请求发送的数据。

配置

控制请求执行方式的选项集。

示例

发起一个GET请求

import "experimental/http/requests"

response = requests.do(url: "http://example.com", method: "GET")

requests.peek(response: response)

发起一个需要授权的GET请求

import "experimental/http/requests"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "TOKEN")

response =
    requests.do(
        method: "GET",
        url: "http://example.com",
        headers: ["Authorization": "token ${token}"],
    )

requests.peek(response: response)

使用查询参数进行GET请求

import "experimental/http/requests"

response = requests.do(method: "GET", url: "http://example.com", params: ["start": ["100"]])

requests.peek(response: response)


Flux的未来

Flux 正在进入维护模式。您可以像现在一样继续使用它,而无需对您的代码进行任何更改。

阅读更多

InfluxDB 3 开源版本现已公开Alpha测试

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

我们将发布两个产品作为测试版的一部分。

InfluxDB 3 核心,是我们新的开源产品。 它是一个用于时间序列和事件数据的实时数据引擎。 InfluxDB 3 企业版是建立在核心基础之上的商业版本,增加了历史查询能力、读取副本、高可用性、可扩展性和细粒度安全性。

有关如何开始的更多信息,请查看: