Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda