Back

[SOLVED] Function : globale variable

  • 0
  • Functions
Mickaël LT
8 Mar, 2023, 10:11

Hi, Is there a way to define globale variable in a project to use it between multiple functions ? For example the variable APPWRITE_FUNCTION_ENDPOINT need to be available for each function we deploy, but we have to declare it in each function...

TL;DR
The user wanted to know if there was a way to define global variables in a project to use them across multiple functions. The answer is that currently, global variables cannot be defined, but it is planned as a feature in the next iteration of Appwrite. The user will need to define the variables manually in each function for now.
Meldiron
8 Mar, 2023, 10:12

Hey there 👋 As of right now, you will need to define them manually in each function. Thanfully, in next Functions iteration global variables is a planned feature. I would expect this to be out in Appwrite 1.4. No active work is done yet, bit I plan to start it soon

Mickaël LT
8 Mar, 2023, 10:16

Ok perfect, glad to see it in the next evolution 👍

Mickaël LT
8 Mar, 2023, 10:22

And is there a way to define the variable in a local file ( for exemple .env), and then when we deploy with the appwrite-cli, it will initialise all variable coming from this file ?

Meldiron
8 Mar, 2023, 10:27

When using Appwrite CLI, it generates appwrite.json. In there, under function, you can add variables key and put key&value pairs of your variables. With that, every deploy will remove all existing variables and apply variables from appwrite.json.

Meldiron
8 Mar, 2023, 10:27
Mickaël LT
8 Mar, 2023, 10:50

Nice, thanks for your answer

Drake
8 Mar, 2023, 17:20

Make sure to 👍🏼 this issue to follow along with the progress! https://github.com/appwrite/appwrite/issues/3530

Meldiron
9 Mar, 2023, 12:09

[SOLVED] Function : globale variable

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more