Back

[SOLVED] Server Functions Caching variables.

  • 0
  • Functions
Capone
28 Jun, 2023, 14:52

It may be that I am using the wrong method to send variables to the server functions, but if I create execution with one value, and then again with a different value, the function fires with the original value and not the new one.

I have attached a screenshot of how I am getting the variables from the execution.

Thanks

TL;DR
The user had a server function that was caching variables and causing issues. They received some advice on using `req.payload` instead of `process.env`. They were also advised to avoid using `then` and instead use `async/try/await/catch`. They mentioned that the function was returning the wrong `listid` and that running the function with different values still resulted in the function using the original value. The user also mentioned that they changed some code to use a space instead of `$` but the function was still using `$` instead. The solution was not explicitly stated in the thread.
Capone
28 Jun, 2023, 15:09

In addition, I have changed code in the function to create a string seperated by "$" to use a " " instead, however the function is still creating strings using "$", so the old code.

Drake
28 Jun, 2023, 15:28

How are you executing your function?

Drake
28 Jun, 2023, 15:28

btw, you should probably only parse once 😜

Capone
28 Jun, 2023, 15:38

You are right, I have changed that now!

Capone
28 Jun, 2023, 15:39

Also noticed I have sent the wrong function, that one is working fine, This is the one I am having issues with

Capone
28 Jun, 2023, 15:52
Capone
28 Jun, 2023, 15:53

Then this is how it is excecuted

Capone
28 Jun, 2023, 15:53
Capone
28 Jun, 2023, 15:54

If I run the function shortly after each other but with different listid, the function will execute with the first listid, and therefore cause an issue as the document already exists, despite the second listid being sent as the value

Capone
28 Jun, 2023, 15:55
Capone
28 Jun, 2023, 15:56

you can see here the listid sent is the one on ln 267, but the function returns the wrong listid

Drake
28 Jun, 2023, 17:21

Btw, I highly advise against using then. It's much clearer to just using async/try/await/catch

Drake
28 Jun, 2023, 17:22

Can you try to use req.payload instead of process.env?

Capone
28 Jun, 2023, 21:00

Ah perfect, that seems to be working now. Thanks for the help!

Drake
28 Jun, 2023, 21:26

[SOLVED] Server Functions Caching variables.

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