How can I use environment variables in lambda functions?
Options
![devben](https://us.v-cdn.net/6037124/uploads/userpics/XX4MFWKNOVFS/nRGEWZK7GUGE5.png)
devben
Member ✭
How can I use environment variables in lambda functions?
In my Workspace Settings I created a env called "apiKey".How can I use it in the code of my Lambda Function? If I try to log it or use it its always undefined. In the docs it says u can use it everywhere. I also tried $var.apikey and $apiKey.
😒plz help
https://docs.xano.com/working-with-data/variables#environment-variables
Best Answer
-
ok i figured it out…
In the "Function Stack" I need to use "Get Environment Variables" before my lambda.
Notice how I defined "return as envs".
In the "Lambda Function"´s code I can then simply use the $var keyword.
//Like so… const { apiKey } = $var.envs; console.log(`myApiKey: ${apiKey}`);
👨🎓^_^
Answers
-
Thanks for sharing the solution, @devben! 😊
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback