1.4 KiB
1.4 KiB
title | description | menu | weight | ||||||
---|---|---|---|---|---|---|---|---|---|
http.get() function | The `http.get()` function submits an HTTP GET request to the specified URL with headers and returns the HTTP status code as an integer and the response body as a byte array. |
|
301 |
The http.get()
function submits an HTTP GET request to the specified URL with headers
and returns the HTTP status code as an integer and the response body as a byte array.
Function type: Miscellaneous
{{% warn %}}
The http.get()
function is currently experimental and subject to change at any time.
By using this function, you accept the risks of experimental functions.
{{% /warn %}}
import "experimental/http"
http.get(
url: "http://localhost:9999/",
headers: {x:"a", y:"b", z:"c"}
)
Parameters
url
The URL to send the GET request to.
Data type: String
headers
Headers to include with the GET request. Headers are represented by key-value pairs.
Data type: Object
Examples
Get the status of InfluxDB
import "influxdata/influxdb/secrets"
import "experimental/http"
token = secrets.get(key: "READONLY_TOKEN")
response = http.get(
url: "http://localhost.com:9999/health",
headers: {Authorization: "Token ${token}"}
)
status = response.statusCode
body = string(v: response.body)