Navigation

    APPDRAG Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular

    REMINDER

    Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

    Global Variables on Cloud Backend API Functions

    Announcements
    3
    6
    539
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Wassim
      Wassim last edited by

      Hello,
      More info here:
      https://changelog.appdrag.com/features/global-vars-on-cloudbackend-api-functions

      1 Reply Last reply Reply Quote 2
      • Daniel Mulroy
        Daniel Mulroy last edited by

        This is such a life-saver! Bravo!

        1 Reply Last reply Reply Quote 1
        • Pierre SULPICE
          Pierre SULPICE last edited by

          That's a very very good news, omg, thanks a lot !

          1 Reply Last reply Reply Quote 1
          • Daniel Mulroy
            Daniel Mulroy last edited by

            I literally wrote a SQL Select function JUST to get secrets from any function while requiring an API token for security..... now I can just use this 🙂

            1 Reply Last reply Reply Quote 2
            • Daniel Mulroy
              Daniel Mulroy last edited by Daniel Mulroy

              Okay... small issue.

              Because it's passed in through the context variable, I can't access it outside the handler function, is that right?

              Unlike the process.env function, the context variable is only available after being passed to the handler / invocation function.

              I have a case where I need it outside the handler functinon. Is it possible?

              
              importantVar = "this is the global variable I would like to use"
              
              doSomethingImportantWith(importantVar);
              
              exports.handler = (event, context, callback) => {
                  // Rest of function goes here
              }
              1 Reply Last reply Reply Quote 0
              • Wassim
                Wassim last edited by

                Hey,
                Well to have it available without the need of republishing your function it has to be in the context. The ENV variables available for each function that needs publish every time you modify them are available globally (as you already know).

                Can you explain why you need to have your importantVar and doSomethingImportantWith outside the handler scope? Maybe I can help you achieve it another way.

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post