test firebase

This commit is contained in:
tuanvu
2025-12-09 10:38:41 +01:00
parent c581f1511f
commit 5feb75a0c7
4 changed files with 112 additions and 72 deletions

View File

@@ -0,0 +1,21 @@
import { collection, getDocs } from "firebase/firestore";
import { db } from "../firebase_config";
export type Ressource = {
id: number;
name: string;
type: string;
Image: string;
};
export async function getRessources(): Promise<Ressource[]> {
try {
const ressourcesCol = collection(db, "ressources");
const snapshot = await getDocs(ressourcesCol);
const list = snapshot.docs.map((doc) => doc.data() as Ressource);
return list;
} catch (err) {
console.log("Firestore Error:", err);
return [];
}
}