1
我正在關注This教程,嘗試將一些功能部署到Firebase,並且我可以將它們成功部署到我的項目ID。當訪問所提供的URL下面的函數,我得到的錯誤:無法處理請求使用Firebase雲功能部署/測試功能
// The Cloud Functions for Firebase SDK to create Cloud Functions and setup
triggers.
const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require ('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.date = functions.https.onRequest((req, res) => {
let format = req.query.format;
const date = moment().format();
res.status(200).json({ date: date});
})
我的火力地堡控制檯日誌本上執行:
ReferenceError: moment is not defined
at exports.date.functions.https.onRequest (/user_code/index.js:10:24)
at cloudFunction (/user_code/node_modules/firebase-
functions/lib/providers/https.js:26:41)
at /var/tmp/worker/worker.js:635:7
at /var/tmp/worker/worker.js:619:9
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
我package.json
在我functions
文件夾中有"moment": "^2.19.1"
依賴關係下。
我在做什麼錯?我如何定義moment
?
當然..謝謝:) –