How to use WritePrecision in javascript client?

trying to get a reference for it using

const { InfluxDB, Point, WritePrecision } = require('@influxdata/influxdb-client');

and then trying;

const influxDbApi = new InfluxDB({url: influxDbUrl, token: influxDbToken}).getWriteApi(influxDbOrg, influxDbBucket, WritePrecision.s);

but getting instead

Cannot read property 's' of undefined

any ideas how I can set a precision?

Hello @bonesoul,
When I do:

const influxDB = new InfluxDB({url, token})
const writeApi = influxDB.getWriteApi(org, bucket, WritePrecision.s) 
function writeExample(value){
          const point1 = new Point('temperature')
          .tag('example', 'index.html')
          .floatField('value', value)

It works for me without errors.
Can you please share your package.json ?

"@influxdata/influxdb-client": "1.2.0"

i’m missing the latest version maybe?

tried your example and getting; ReferenceError: WritePrecision is not defined

my full package.json;


“name”: “migration tool”,

“version”: “1.0.0”,

“description”: “”,

“main”: “”,

“scripts”: {

"test": "echo \"Error: no test specified\" && exit 1"


“author”: “”,

“license”: “ISC”,

“dependencies”: {

"@influxdata/influxdb-client": "1.2.0",

"app-module-path": "2.2.0",

"cli-progress": "3.8.1",

"colors": "1.4.0",

"config": "3.3.1",

"glob": "7.1.6",

"glob-promise": "3.4.0",

"js-yaml": "3.13.1",

"lodash": "4.17.15",

"moment": "2.25.0",

"mongoose": "5.9.11",

"pg-promise": "10.5.2",

"winston": "3.2.1"



I am using
@influxdata/influxdb-client”: “1.2.0-nightly.9”
Let me know if that helps? Sorry for the delay.