我正在嘗試將一些隨機(jī)數(shù)據(jù)推送到云 Firestore。因此,我使用帶有 - firebase init 函數(shù)的云函數(shù)初始化了項(xiàng)目。在函數(shù)目錄中,我有一個(gè)文件 seed.js,其中包含發(fā)送數(shù)據(jù)的代碼。使用 faker 生成數(shù)據(jù)。const faker = require("faker");const db = admin.firestore();const fakeIt = () => { return db.collection("customers").add({ username: faker.internet.userName(), avatar: faker.internet.avatar(), bio: faker.hacker.phrase() });};Array(20) .fill(0) .forEach(fakeIt);當(dāng)我運(yùn)行 node seed.js 時(shí),我收到了下面描述的錯(cuò)誤PS C:\Users\Ghost\Random Projects\Algolia\functions> node .\seed.js(node:1636) UnhandledPromiseRejectionWarning: Error: Unable to detect a Project Id in the current environment.To learn more about authentication and Google APIs, visit:https://cloud.google.com/docs/authentication/getting-started at _getDefaultProjectIdPromise.Promise (C:\Users\Ghost\Random Projects\Algolia\functions\node_modules\google-auth-library\build\src\auth\googleauth.js:90:31) at process._tickCallback (internal/process/next_tick.js:68:7)(node:1636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 21)(node:1636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.(node:1636) UnhandledPromiseRejectionWarning: Error: Unable to detect a Project Id in the current environment.To learn more about authentication and Google APIs, visit:https://cloud.google.com/docs/authentication/getting-started at _getDefaultProjectIdPromise.Promise (C:\Users\Ghost\Random Projects\Algolia\functions\node_modules\google-auth-library\build\src\auth\googleauth.js:90:31) at process._tickCallback (internal/process/next_tick.js:68:7)
未能將數(shù)據(jù)發(fā)送到 Cloud Firestore
牛魔王的故事
2021-09-30 15:01:45