Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
unable to set data to Cloud Firestore from web page

Im trying to set some data from a text input from a web page to cloud firestore. I have this in one html file with the below code in a tag.

I used the code based on Firestore docs.

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.1.2/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.1.2/firebase-analytics.js";
import { getFirestore } from "https://www.gstatic.com/firebasejs/8.10.0/firebase-firestore.js";
       
const firebaseConfig = {...};
      
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const db = getFirestore();

   var name = getInputVal('cbname');

   function clubname() {
        
   db.collection("latest").add({
        clubName: name,
        })
    .then((docRef) => {
         console.log("Document written with ID: ", docRef.id);
        })
    .catch((error) => {
         console.error("Error adding document: ", error);
        });
    }

im using this code to get the input.

<label for="cbname">Club Name</label>
<input type="text" id="cbname" name="clubname">

<button class="save-button" onclick="clubname()" type="submit">Save</button>

ive tried a few different ways and I have ben unable to set data to a new document, add data to an existing document or update a document.

But for now, im just looking to set data.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It looks like you are importing getFirestore from wrong version of Firebase API, try this:

import { getFirestore } from "https://www.gstatic.com/firebasejs/9.1.2/firebase-firestore.js";
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda