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

211
Visualizações
Getting firebase is not defined on setting document in html/ javascript

So, basically i am trying to save data in firebase an am getting the error "firebase is not defined" my code:-

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.1/firebase-app.js";
      const firebaseConfig = {
        apiKey: "",
        authDomain: "",
        projectId: "",
        storageBucket: "",
        messagingSenderId: "",
        appId: ""
      };
    
      // Initialize Firebase
      const app = initializeApp(firebaseConfig);
      firebase                                                  // getting error over here
  .firestore()
  .collection("books")
  .add({
    title: "Of Mice and Men",
  })
  .then((ref) => {
    console.log("Added doc with ID: ", ref.id);
    // Added doc with ID:  ZzhIgLqELaoE3eSsOazu
  });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Since version 9 of its JavaScript SDK, Firebase has switched to a new modular syntax where you import individual functions. You'll have to choose whether you want to use the new syntax, or continue using the previous syntax through its compatibility layer.

To import the compatibility libraries, use:

// v9 compat packages are API compatible with v8 code
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

To then switch to the new syntax, follow the instructions in the same upgrade guide, and in the v9 tab of the code samples in the rest of the documentation.

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