【发布时间】:2021-12-08 01:36:13
【问题描述】:
伙计们。我正在使用 Google Firestore 将一些数据保存在数据库中。例如,如果我使用 Google 提供的代码在数据库中替换或创建新文档,我会收到错误:Uncaught SyntaxError: Unexpected reserved word。我知道问题是 await 只能与异步函数一起使用,但这些不是我创建的函数。它们是从 Firestore 库中导入的,我使用的是 Google 提供的代码。这里有什么问题?谢谢。
import { doc, setDoc } from "firebase/firestore";
await setDoc(doc(db, "cities", "LA"), {
name: "Los Angeles",
state: "CA",
country: "USA"
})
【问题讨论】:
标签: javascript google-cloud-firestore async-await