firebase 회원가입 중에서...
Register.vue 스크립트 내용 script> import { ref } from "vue"; import { auth, USER_COLLECTION } from "../firebase" import { useRouter } from "vue-router" export default { setup() { const email = ref(""); const username = ref(""); const password = ref(""); const loading = ref(false); const router = useRouter(); const onRegiser = async () => { try { loading.value = true const { user } = await auth.createUserWithEmailAndPassword(email.value, password.value) const doc = USER_COLLECTION.doc(user.uid) await doc.set({ uid: user.uid, email: email.value, profile_image_url: '/profile.jpeg', num_tweets: 0, followers: [], followings: [], created_at: Date.now() }) alert("회원가입 성공") router.push('/login') } catch(e) { // console.log("create user with email and password error:",e) alert(e.message) } finally { loading.value = false } }; return { username, email, password, onRegiser, loading, }; }, }; script> firebase/ index.js 스크립트 내용 import firebase from 'firebase' const firebaseConfig = { apiKey: "AIzaSyA8429twvLbAUdo2v2c09mplxb5RmdoRp0", authDomain: "twitter-clone-inflearn-dfe0e.firebaseapp.com", projectId: "twitter-clone-inflearn-dfe0e", storageBucket: "twitter-clone-inflearn-dfe0e.appspot.com", messagingSenderId: "194204341657", appId: "1:194204341657:web:30c2f77d320f3f78b16f08" }; firebase.initializeApp(firebaseConfig) export const auth = firebase.auth() export const db = firebase.firestore() export const storage = firebase.storage() export const USER_COLLECTION = db.collection("users")