Firebase Realtime数据库: 我想从Firebase实时数据库中获取随机数据,例如此链接中的图片(https://drive.google.com/file/d/1ZqEugWRN03ddaN59nFqIbw0NSCpDNGaJ/view?usp=sharing) 并立即将其倒入图形Highcharts中,我对javascript中的编程代码感到困惑。我的代码正确吗?
const numbers = 2000;
const randomIndex = Math.floor(Math.random() * numberOfUsers);
var FireBase2 = firebase.database().ref('Perangkat2/hujan_menit/1/hujanpermenit');
var result2; //humidity variable
var snap = Firebase2.limitToFirst(randomIndex).limitToLast(1).once('value').then(datasnapshot =>{
result2 = parseFloat(datasnapshot.val())
};
FireBase2.on("value", snap)
Highcharts.setOptions({
global: {
useUTC: false
}
});