我正试图通过InfluxDB客户端从node.js中的InfluxDB服务器获取数据,但当我进行查询时,我得到了一个"类型错误:t.complete不是函数";错误我可以在控制台中看到,客户端获取数据,然后产生此错误。
JS客户端代码:
const fluxQuery =
'from(bucket:"data") |> range(start: 0) |> filter(fn: (r) => r._measurement == "devices") |> filter(fn: (r) => r["_field"] == "wreal1") |> last()';
queryApi.queryRows(fluxQuery, {
next(row, tableMeta) {
const o = tableMeta.toObject(row)
console.log(o)
}
});
控制台:
{
result: '_result',
table: 0,
_start: '2021-06-17T22:31:04.305309987Z',
_stop: '2021-06-17T23:02:08.128895474Z',
_time: '2021-06-17T23:02:07.278424896Z',
_value: 3159.7,
_field: 'wreal1',
_measurement: 'devices',
disp: '1'
}
C:UsersusuarioDesktopproyectonode_modules@influxdatainfluxdb-clientdistindex.js:1
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("URL"),
.................
return G(t.toString())}const K="function"==typeof Symbol&&Symbol.observable||"@@observable";
TypeError: t.complete is not a function
at Object.complete (C:UsersusuarioDesktopproyectonode_modules@influxdatainfluxdb-clientdistindex.js:1:4568)
at Object.complete (C:UsersusuarioDesktopproyectonode_modules@influxdatainfluxdb-clientdistindex.js:1:948)
at IncomingMessage.complete (C:UsersusuarioDesktopproyectonode_modules@influxdatainfluxdb-clientdistindex.js:16:8791)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
[nodemon] app crashed - waiting for file changes before starting...
我使用的是模块中的1.14版本,我尝试安装1.13版本,但出现了相同的错误。
需要完成查询:
queryApi.queryRows(fluxQuery, {
next(row, tableMeta) {
const o = tableMeta.toObject(row)
console.log(o)
},
error(error) {
console.error(error)
console.log('nFinished ERROR')
},
complete() {
console.log('nFinished SUCCESS')
},
});