I’m getting error for running the above query in influxdb 2.2 :
Error: A 401 Unauthorized error occurred: {“code”:“unauthorized”,“message”:“Unauthorized”}
Hi @Nik,
Here is an example based on the V1 client library.
// Connect over HTTPS
const Influx = require('influx');
const os = require('node:os');
// influx cloud example
const influx = new Influx.InfluxDB({
host: 'us-east-1-1.aws.cloud2.influxdata.com',
port: 443,
protocol: 'https',
database: 'server',
username: '<USERNAME>',
password: '<TOKEN>',
})
// influx OSS example
const influx = new Influx.InfluxDB({
host: 'localhost',
port: 8086,
protocol: 'http',
database: 'server',
username: '<USERNAME>',
password: '<TOKEN>',
})
influx.query('select * from cpu').then(results => {
console.log(results)
})
In future please remember this forum is here to promote collaboration and goodwill between us and the community. My initial statement was to check if you have completed this step before moving further. Using statements such as “I don’t want baseless statements” in future will not get you further in your queries.