add numbering and alignment
parent
7a3bfee9ff
commit
e4612cd6c1
|
@ -62,14 +62,13 @@ yarn install
|
|||
## Boilerplate for the InfluxDB Javascript client library
|
||||
Use the Javascript library to write data to and query data from InfluxDB.
|
||||
|
||||
To write a data point to InfluxDB using the JavaScript library, import the latest InfluxDB Javascript library in your script.
|
||||
1. To write a data point to InfluxDB using the JavaScript library, import the latest InfluxDB Javascript library in your script.
|
||||
|
||||
```js
|
||||
import {InfluxDB, Point} from 'https://unpkg.com/@influxdata/influxdb-client/dist/index.browser.mjs'
|
||||
```
|
||||
|
||||
Next, define constants for your InfluxDB [bucket](/v2.0/organizations/buckets/), [organization](/v2.0/organizations/), [token](/v2.0/security/tokens/), and `proxy` which relies on a proxy to forward requests to the target InfluxDB instance.
|
||||
|
||||
2. Define constants for your InfluxDB [bucket](/v2.0/organizations/buckets/), [organization](/v2.0/organizations/), [token](/v2.0/security/tokens/), and `proxy` which relies on a proxy to forward requests to the target InfluxDB instance.
|
||||
|
||||
```js
|
||||
const proxy = '/influx'
|
||||
|
@ -78,7 +77,7 @@ const org = 'example-org'
|
|||
const bucket = 'example-bucket'
|
||||
```
|
||||
|
||||
Instantiate the InfluxDB JavaScript client and pass in the `proxy` and `token` parameters.
|
||||
3. Instantiate the InfluxDB JavaScript client and pass in the `proxy` and `token` parameters.
|
||||
|
||||
```js
|
||||
const InfluxDB = new InfluxDB({proxy, token})
|
||||
|
@ -87,7 +86,7 @@ const InfluxDB = new InfluxDB({proxy, token})
|
|||
## Write data to InfluxDB with JavaScript
|
||||
Use the Javascript library to write data to InfluxDB.
|
||||
|
||||
Use the `getWriteApi` method of the InfluxDB client to create a **write client**. Provide your InfluxDB `org` and `bucket`.
|
||||
1. Use the `getWriteApi` method of the InfluxDB client to create a **write client**. Provide your InfluxDB `org` and `bucket`.
|
||||
|
||||
```js
|
||||
const writeApi = InfluxDB.getWriteApi(org, bucket)
|
||||
|
@ -128,13 +127,13 @@ writeApi
|
|||
## Query data from InfluxDB with JavaScript
|
||||
Use the Javascript library to query data from InfluxDB.
|
||||
|
||||
Use the `getQueryApi` method of the `InfluxDB` client to create a new **query client**. Provide your InfluxDB `org`.
|
||||
1. Use the `getQueryApi` method of the `InfluxDB` client to create a new **query client**. Provide your InfluxDB `org`.
|
||||
|
||||
```js
|
||||
const queryApi = influxDB.getQueryApi(org)
|
||||
```
|
||||
|
||||
Create a Flux query (including your `bucket` parameter).
|
||||
2. Create a Flux query (including your `bucket` parameter).
|
||||
|
||||
```js
|
||||
const fluxQuery =
|
||||
|
@ -144,7 +143,8 @@ const fluxQuery =
|
|||
```
|
||||
|
||||
The **query client** sends the Flux query to InfluxDB and returns line table metadata and rows.
|
||||
Use the `next` method to iterate over the rows.
|
||||
|
||||
3. Use the `next` method to iterate over the rows.
|
||||
|
||||
```js
|
||||
queryApi.queryRows(fluxQuery, {
|
||||
|
|
Loading…
Reference in New Issue