Reputation: 1247
I set environment variables but can't refer to them inside cloud function. What I did is like this.
firebase functions:config:set myproject.id=projectid1234 myproject.location=us-central1
And I saw the variables are actually set.
{
"myproject": {
"location": "us-central1",
"id": "projectid1234"
}
}
And my function is like this.
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()
exports.myFunction = functions.https.onCall((data, context) {
const projectId = functions.config().myproject.id
...
})
And error log
Unhandled error TypeError: Cannot read property 'id' of undefined
What am I wrong with this? The variables I set are the project's id and the project's location.
Upvotes: 0
Views: 532
Reputation: 83058
As explained in the doc, you need to redeploy your Cloud Functions to make the new configuration available.
Upvotes: 2