File size: 744 Bytes
01396d4
 
 
1be0869
 
01396d4
1be0869
 
01396d4
 
 
 
 
 
 
 
 
1be0869
01396d4
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { initializeApp } from "firebase/app";
import { getDatabase, ref, get, child } from "firebase/database";

// ARSITEKTUR FRONTEND: Hanya gunakan ekstrak data publik.
// DILARANG memasukkan private_key ke object ini.
const firebaseConfig = {
  projectId: "dtabase-80c9a",
  databaseURL: "https://dtabase-80c9a-default-rtdb.asia-southeast1.firebasedatabase.app"
};

const app = initializeApp(firebaseConfig);
export const db = getDatabase(app);

export const fetchAnichinData = async () => {
  const dbRef = ref(db);
  try {
    const snapshot = await get(child(dbRef, `anichin_database`));
    return snapshot.exists() ? snapshot.val() : null;
  } catch (error) {
    console.error("Firebase fetch error:", error);
    return null;
  }
};