// 1. 필요한 도구들을 인터넷에서 가져옵니다 import { initializeApp } from "https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js"; import { getFirestore, collection, addDoc } from "https://www.gstatic.com/firebasejs/10.8.0/firebase-firestore.js"; // 2. 아까 찾으신 여러분의 진짜 열쇠뭉치예요! const firebaseConfig = { apiKey: "AIzaSyC-wVDUEUa2-lOCRepGPZlrMsYkCjUIp2Y", authDomain: "test-project-af7df.firebaseapp.com", projectId: "test-project-af7df", storageBucket: "test-project-af7df.firebasestorage.app", messagingSenderId: "333849623263", appId: "1:333849623263:web:d8a0b56eaa77235e9d476a" }; // 3. 무전기 전원을 켭니다 (초기화) const app = initializeApp(firebaseConfig); const db = getFirestore(app); // 4. [데이터 저장] 버튼을 누르면 실행될 마법 함수입니다 window.saveData = async function() { try { // 'my_test'라는 칸에 메시지를 저장합니다 const docRef = await addDoc(collection(db, "my_test"), { content: "와! 내가 직접 연결했어!", time: new Date() }); alert("성공! 가방에 쪽지를 넣었어요. ID: " + docRef.id); } catch (e) { alert("앗! 에러가 났어요. 보안 규칙을 확인해보세요: " + e); } }

파이어베이스 연결 테스트