Files
mmm-projet/services/ressourcesService.ts
2025-12-09 10:38:41 +01:00

21 lines
538 B
TypeScript

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 [];
}
}