Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Nuxt firebase escribe el documento después de que falle createUserWithEmailAndPassword

La idea del formulario de registro es

  1. agregue el correo electrónico y la contraseña del usuario a la autenticación de base de fuego, esto es exitoso, luego
  2. agregue un nuevo documento usando su uid como identificación del documento e inserte el campo de calle y el valor; a la recopilación de profile , falló sin error.

El usuario y el correo electrónico se agregan a los usuarios de autenticación en la consola de firebase, pero la escritura del documento sigue sin tener éxito y tampoco hay errores en la consola.

He estado rascándome la cabeza por un tiempo.

Aquí está mi código

 <template> <v-form @submit.prevent="createUser"> <v-text-field v-model="register.email" label="Email" required /> <v-text-field v-model="register.password" label="Password" required /> <v-text-field v-model="register.street" required label="Street" /> <v-btn type="submit" > Register </v-btn> </v-form> </template> <script> import Vue from 'vue' import { createUserWithEmailAndPassword, onAuthStateChanged } from 'firebase/auth' import { doc, setDoc } from 'firebase/firestore' import { auth, db } from '~/plugins/firebase.js' export default Vue.extend({ data () { return { register: {} } }, methods: { async createUser () { await createUserWithEmailAndPassword( auth, this.register.email, this.register.password ).catch((error) => { console.log(error.code) console.log(error.message) }) onAuthStateChanged( auth, (user) => { if (user) { const ref = doc(db, 'profile', user.uid) const document = { street: this.register.street } try { setDoc(ref, document) } catch (e) { alert('Error!') console.error(e.code) console.error(e.message) } } } ) } } }) </script>

regla de firestore sin restricción

 rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read; allow write; } } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intenta lo siguiente:

 async createUser () { await createUserWithEmailAndPassword( auth, this.register.email, this.register.password ) .then((user) => { this.writeToFirestore(user) }) .catch((error) => { console.log(error.code) console.log(error.message) }) }, async writeToFirestore(user) { if (user) { const ref = doc(db, 'profile', user.id) const document = { street: this.register.street } try { setDoc(ref, document) } catch (e) { alert('Error!') console.error(e.code) console.error(e.message) } } },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!