<script type="module">
import {InfluxDB, Point} from 'influxdb/influxdb-client/dist/index.browser.mjs';
amap.saveInflux = function(message){
var writeApi = new InfluxDB({
url:"http://10.10.2.208:8086",
token: "fch"
}).getWriteApi("", "uwb", "ns");
const point1 = new Point('uwb')
.tag('x', message['x'])
.tag('y', message['y'])
.intField('datetime', Math.round(new Date().getTime()/1000).toString())
.intField('station', message['station'])
.intField('tagid', message['TagID'])
// 写入数据
writeApi.writePoint(point1)
writeApi.close().then((e) => {
console.log('WRITE FINISHED')
}).catch(e => {
console.log('WRITE FAILED', e)
})
}
</script>
增加类型
vim /etc/mime.types
application/javascript js mjs
修改js
influxdb-client/dist/index.browser.mjs
this.sendOptions={method:"POST",mode:"no-cors",