Today, there is new feature of Cloud Functions for Firebase which is running functions on a schedule. So I tried to test the sample code.
index.js file
exports.scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) => {
console.log(‘This will be run every 5 minutes!’);
});
But when I tried to deploy this, I got the following error message:
Error: Error occurred while parsing your function triggers.
TypeError: functions.pubsub.schedule is not a function
My firebase tools version is 6.7
(updated today)
What is the solution?
I checked the example git code in here (https://github.com/firebase/functions-samples/blob/master/delete-unused-accounts-cron/functions/index.js)
But it also cause the same error:
functions.pubsub.schedule is not a function
Can anyone help me with this problem?
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!');
});