Comments (2)
Try this:
const runtimeConfig = require('cloud-functions-runtime-config');
exports.helloWorld = (req, res) => {
return runtimeConfig.getVariable('global', 'var')
.then((val) => res.status(200).send(`Var is ${val}`))
.catch((err) => res.status(500).send(`Problem resolving var: ${err}`));
};
The difference is that this example does a lookup at the time of invocation instead of during the creation of a new function instance. GCP may reuse function instances, that's why we might see the same value for a while when we do the lookup in global scope.
@DazWilkin has written a great article that explains the different scopes here.
from cloud-functions-runtime-config.
It was precisely that ! Sorry for the false alert :)
from cloud-functions-runtime-config.
Related Issues (9)
- Consider global scope to 'cache' deployment (!) config HOT 3
- basic example needs update HOT 2
- get entire config at once? HOT 1
- npm install fails
- Feature Request "getVariables" HOT 5
- "A Not Found error" HOT 9
- Default credentials in Cloud Functions throws Not Found HOT 2
- Add GCLOUD_PROJECT to README.md and throw error if missing HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloud-functions-runtime-config.