Read Data
const { rt } = require("../config/firebase");
// for realtime purpose
const reference = rt.ref("block"); // change your .ref() name as you wish
const ReadService = {
async run(){
// check if data (block/12345) exist in realtime database..
reference.child("12345").on(
"value",
async (snapshot) => {
if (snapshot.val()) {
console.log(snapshot.val())
}
else console.log(snapshot.val(), "data not exist");
},
(errorObject) => {
console.log("The read failed: " + errorObject.name);
}
);
}
}
service.run();
module.exports = ReadService ;
Last updated
Was this helpful?