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

368
Views
¿Por qué setDoc (doc (db, colref, id), {...}) no crea un nuevo documento en firestore?

Busqué el documento de Firestore y veo este método para crear un nuevo documento con una identificación personalizada

 import { doc, setDoc } from "firebase/firestore"; // Add a new document in collection "cities" await setDoc(doc(db, "cities", "LA"), { name: "Los Angeles", state: "CA", country: "USA" });

Sin embargo, cuando implemento de la siguiente manera, devuelve undefined: doc no está definido

 createUserWithEmailAndPassword(auth, txtEmail.value, txtPassword.value).then((userCredential) => { setDoc(doc(db, 'users', userCredential.user.uid), { email: txtEmail.value, name: "nickname", password: txtPassword.value, on_line: false, creat_time: Timestamp.fromDate(new Date()) }).then((docref) => { txtEmail.value = ""; txtPassword.value = ""; create_alert("success", userCredential.user + " sign up success"); }); })

archivo completo:

 import { db, auth } from "./config"; import {collection, getDoc, addDoc, updateDoc, setDoc, Timestamp} from "firebase/firestore"; import {getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword} from "firebase/auth"; new_account = () => { var txtEmail = document.getElementById('inputEmail'); var txtPassword = document.getElementById('inputPassword'); createUserWithEmailAndPassword(auth, txtEmail.value, txtPassword.value).then((userCredential) => { console.log("User: " + txtEmail.value + " has succesfully sign up"); setDoc(doc(db, 'users', userCredential.user.uid), { email: txtEmail.value, name: "nickname", password: txtPassword.value, on_line: false, creat_time: Timestamp.fromDate(new Date()) }).then((docref) => { txtEmail.value = ""; txtPassword.value = ""; create_alert("success", userCredential.user + " sign up success"); });

Arriba está la mayor parte de mi archivo.

about 4 years ago · Santiago Trujillo
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!