【发布时间】:2019-09-09 10:52:17
【问题描述】:
今天,Cloud Functions for Firebase 有一个新功能,可以按计划运行功能。所以我尝试测试示例代码。
index.js 文件
exports.scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) => {
console.log(‘This will be run every 5 minutes!’);
});
但是当我尝试部署它时,我收到以下错误消息:
Error: Error occurred while parsing your function triggers.
TypeError: functions.pubsub.schedule is not a function
我的 firebase 工具版本是 6.7(今天更新)
解决办法是什么?
我在这里检查了示例 git 代码 (https://github.com/firebase/functions-samples/blob/master/delete-unused-accounts-cron/functions/index.js)
但它也会导致同样的错误:
functions.pubsub.schedule 不是函数
谁能帮我解决这个问题?
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
});
【问题讨论】:
标签: firebase google-cloud-functions firebase-cli