diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/_index.md b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md new file mode 100644 index 000000000..d56bfae6a --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md @@ -0,0 +1,31 @@ +--- +title: Flux HTTP package +list_title: HTTP package +description: > + The Flux Experimental HTTP package provides functions for transferring data + using HTTP protocol. + Import the `experimental/http` package. +menu: + v2_0_ref: + name: HTTP + identifier: HTTP-exp + parent: Experimental +weight: 201 +v2.0/tags: [functions, http, package] +--- + +The Flux Experimental HTTP package provides functions for transferring data +using HTTP protocol. + +{{% warn %}} +The experimental HTTP package is subject to change at any time. +By using this package, you accept the [risks of experimental functions](/v2.0/reference/flux/stdlib/experimental/#use-experimental-functions-at-your-own-risk). +{{% /warn %}} + +Import the `experimental/http` package: + +```js +import "experimental/http" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md new file mode 100644 index 000000000..8a3bd0a38 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -0,0 +1,60 @@ +--- +title: http.get() function +description: > + The `http.get()` function submits an HTTP GET request to the specified URL and + returns the HTTP status code as an integer and the response body as a byte array. +menu: + v2_0_ref: + name: http.get + parent: HTTP-exp +weight: 301 +--- + +The `http.get()` function submits an HTTP GET request to the specified URL 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](/v2.0/reference/flux/stdlib/experimental/#use-experimental-functions-at-your-own-risk). +{{% /warn %}} + +```js +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. + +_**Data type:** Object_ + +## Examples + +##### Get the status of InfluxDB +```js +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) +```