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

299
Visualizações
Uncaught SyntaxError: Unexpected reserved word (await)

guys. I'm using Google Firestore to save some data in a database. If, for example, I use the code provided by Google to replace or create a new document in the database, I get the error: Uncaught SyntaxError: Unexpected reserved word. I know the problem is that await can only be used with asynchronous functions, but these are not functions created by me. They are imported from the Firestore libraries and I'm using the code provided by Google. What is wrong here? Thank you.

import { doc, setDoc } from "firebase/firestore";

await setDoc(doc(db, "cities", "LA"), {
  name: "Los Angeles",
  state: "CA",
  country: "USA"
})
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The "await" only makes the rest of the code wait for the method to finish.
If you want to keep it:

import { doc, setDoc } from "firebase/firestore";

(async function() {
  await setDoc(doc(db, "cities", "LA"), {
    name: "Los Angeles",
    state: "CA",
    country: "USA"
  })
})();

If not:

import { doc, setDoc } from "firebase/firestore";

setDoc(doc(db, "cities", "LA"), {
  name: "Los Angeles",
  state: "CA",
  country: "USA"
});
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