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

225
Views
¿Cómo puedo actualizar el campo "Importante", que se almacena en una subcolección?

¿Cómo puedo actualizar el campo "Importante", que se almacena en una subcolección?

Ver imagen para entender mejor

 import firebaseApp from "../../utils/firebase"; import { getFirestore, doc, updateDoc } from "firebase/firestore"; const firestoreDB = getFirestore(firebaseApp); const USER_DATA = "UsersData"; const TASKS = "Tasks"; const updateImportantValue = async (userID, newValue) => { try { const docRef = doc( firestoreDB, USER_DATA, userID, TASKS, "EyS9R8dHV3EU3WS2PeQo" ); await updateDoc(docRef, { important: newValue, }); console.log(firestoreDB); console.log(USER_DATA); console.log(userID); console.log(TASKS); console.log(newValue); console.log("updateImportantValue - success"); } catch (error) { console.log(error); } };

Lo intenté de esta manera pero me arroja un error:

TypeError: n.indexOf no es una función

 at Function.fromString (index.esm2017.js:1084:1) at ia (index.esm2017.js:16166:1) at updateImportantValue (updateImportantValue.js:9:1) at removeImportant (useTask.js:76:1) at importantButton (TaskData.js:16:1) at onClick (TaskData.js:37:1) at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1) at invokeGuardedCallback (react-dom.development.js:4056:1) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)

Actualizar

Actualización, no estaba recibiendo la identificación de usuario correctamente. Corregí el error y la consola indica que todo estaba correcto, pero en firestore el documento no sufre ningún cambio, el campo "importante" sigue igual.

consola.log

about 4 years ago · Juan Pablo Isaza
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!