Access Appwrite_Function_APIKeys from process.env into req.variables of JSON file using typescript
- 0
- Web
web one was closed. This is building from web one. In my case, appwrite api keys were loaded into nodejs module which can only be accessed by process.env['APPWRITE_FUNCTION_PROJECT_ID']. So i need to load the result of process.env['APPWRITE_FUNCTION_PROJECT_ID'] into req.variables which is used to reques data from JSON file.
and remember im using typewrite
sorry, typescript
When using Appwrite function you don't use process.env
What you mean by that π
appwrite api keys were loaded into nodejs module which can only be accessed by process.env
Sir, iam connecting to appwrite using nodejs and nodejs is running on replit online platform. On that platform, there is secret key menu where I can configure the keys I need to use (were loaded means were configured).. and in this case i use node-appwrite in place of appwrite...
Okay So you have a node backend that has nothing to do with Appwrite functions. Yes?
Then why you need req.variables
for
No, first appwrite keys were configured in appwrite server using the appwrite console. Then from nodejs platform running on replit, appwrite keys were configured in the secrete menu to be used for communicating to appwrite. Once these keys are confugured in secrete menu, they go the module of nodejs which can only be accessed by process.env. remember in this case i am interacting with the server. so i need to retrieve saver data to the JSON file for browser interaction. thats why i need to parse them to req.variables....
I understand all except the req.variables
what you need those for?
JSON file stores data in value pairs, one of the parameters it stores are variables. so i need to parse the variable retrieved from process.env into req.variables of the JSON so that i can now start interacting with JSON file in order to display the data on the browser..
Gotcha
What is the error you're getting?
thats what i was trying to use but dont output anything
Inside an object you can't use ;
or the const
keyword
It should be something like this
req.variables = {
apiKey: process.env['SOME_VAR'],
eventData: process.env['SOME_VAR']
}
...
console.log("apiKEY_case2:" + apiKey);
...
okay sir, let me look at that, will get back to you....
Hey sir, hope you're okay. Decided to change the setting of the APPWRITE KEYS by first testing when I have declared them within the code. Now imagining why console.log() cant output the respective APPWRITE_FUNCTION_ENDPOINT. As per attached file.
Hey sir, hope you're okay. Decided to change the setting of the APPWRITE KEYS by first testing when I have declared them within the code. Now imagining why console.log() cant output the respective APPWRITE_FUNCTION_ENDPOINT. As per attached file.
What do you get in the log
?
Sir, there nothing i see even in the log..
Then the problem is before How did you ran this function?
The code is a typescript file, so i do tsc test4.ts. This generates a .js file. Then after I do node test4.js
Mmm. This won't output anything.
To execute this file you either need to deploy it your Appwrite instance.
Or
You can try this local-server.js
that will let you run your test4.js locally
https://github.com/appwrite/appwrite/issues/5425
Example
https://github.com/byawitz/roadmapper/blob/main/functions/getGitFeatures/local-server.js
Thank you sir, some idea on how to deploy it as appwrite instance in nodejs
Sure The best way would be to check this https://appwrite.io/docs/functions
Here https://discord.com/channels/564160730845151244/1115309346037968948/1115317157383897238 you see the steps in a glance
thank you
Recommended threads
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...
- SyntaxError: Unexpected end of JSON inpu...
I am trying to create a fcm push notification service using appwrite functions with its REST API to invoke that function from my client side app and getting thi...
- Experiencing inconsistent "500 general_u...
I am developing a task management app that uses Appwrite auth. My project is hosted on Appwrite cloud and I've created basic server-side authentication followin...