My problem is trying to define a local function in Firebase Cloud Functions. I would like my function to be global and reusable, but it seems to not export when I deploy using Firebase-CLI.
function mapEvents(data) {
// Very long calculation
...
return events
}
exports.importEvents = functions.https.onRequest((req, res) => {
...
const mappedEvents = mapEvents(data);
...
})
This is the logged error I'm getting in the Firebase console when I run importEvents:
TypeError: this.mapEvent is not a function at module.exports.importEvents.functions.https.onRequest (/user_code/index.js:199:29) at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:26:41)
function
? – A.Queue