more fixes

pull/1345/head
Anaisdg 2020-04-13 15:53:34 -05:00 committed by Scott Anderson
parent 6789f6a29c
commit a649e4c7f8
2 changed files with 12 additions and 13 deletions
content/influxdb/v2.0/reference/api/client-libraries

View File

@ -18,8 +18,8 @@ This guide presumes some familiarity with Go and InfluxDB.
If just getting started, see [Get started with InfluxDB](/v2.0/get-started/).
## Before you begin
1. Go 1.3 or later is required.
1. Install Go 1.3 or later](https://golang.org/doc/install)
2. Download the client package in your $GOPATH and build the package.
```sh
@ -59,18 +59,18 @@ org := "<my-org>"
token := "<my-token>"
//variable to store the url of your local or InfluxDB Cloud instance
url := "<http://localhost:9999>"
``
```
To write data, create the the InfluxDB Go Client and pass in our named parameters: `url` and `token`.
```go
client := influxdb2.NewClient(url, my-token)
client := influxdb2.NewClient(url, token)
```
Create a **write client** with the `WriteApiBlocking` method and pass in your other named parameters: `org` and `bucket`.
```go
writeApi := client.WriteApiBlocking(my-org, my-bucket)
writeApi := client.WriteApiBlocking(org, bucket)
```
To query data, create an InfluxDB **query client** and pass in your InfluxDB `org`.
@ -78,6 +78,7 @@ To query data, create an InfluxDB **query client** and pass in your InfluxDB `or
```go
queryApi := client.QueryApi(org)
```
## Write data to InfluxDB with Go
Use the Go library to write data to InfluxDB.

View File

@ -55,7 +55,7 @@ yarn install
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
3. Update your `./env` and `index.html` with the name of your InfluxDB [bucket](/v2.0/organizations/buckets/), [organization](/v2.0/organizations/), [token](/v2.0/security/tokens/), and `url` which relies upon proxy to forward requests to the target InfluxDB.
3. Update your `./env` and `index.html` with the name of your InfluxDB [bucket](/v2.0/organizations/buckets/), [organization](/v2.0/organizations/), [token](/v2.0/security/tokens/), and `proxy` which relies upon proxy to forward requests to the target InfluxDB.
4. Run the following command to run the application at [http://localhost:3001/examples/index.html]()
```sh
@ -71,22 +71,20 @@ To write a data point to InfluxDB using the JavaScript library, import the lates
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 `url` which relies on a proxy to forward requests to the target InfluxDB instance.
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.
```js
const url = '/influx'
const proxy = '/influx'
const token = '<my-token>'
const org = '<my-org>'
const bucket = '<my-bucket>'
//variable to store the url of your local or InfluxDB Cloud instance
const url = 'http://localhost:9999'
```
Instantiate the InfluxDB JavaScript Client and pass in our named parameters: `url` and `token`.
Instantiate the InfluxDB JavaScript Client and pass in our named parameters: `proxy` and `token`.
```js
const InfluxDB = new InfluxDB({url, token})
const InfluxDB = new InfluxDB({proxy, token})
```
## Write data to InfluxDB with JavaScript
Use the Javascript library to write data to InfluxDB.
@ -111,7 +109,7 @@ writeApi.close()
### Complete example write script
```js
const writeApi = new InfluxDB({url, token})
const writeApi = new InfluxDB({proxy, token})
const writeApi = influxDB.getWriteApi(org, bucket)
// setup default tags for all writes through this API
writeApi.useDefaultTags({location: 'browser'})