Back

[SOLVED] function not running properly

  • 0
  • Functions
rohan
9 Sep, 2023, 21:51

i tried to log the env variables but its logging null

log( 'ENV', JSON.stringify(process.env))

TL;DR
The user had an issue with a function not running properly. They were using ENV variables to initialize the client and it was returning 0 documents. However, when they initialized it directly, it showed the proper result. The issue was due to the user not initializing the API key properly. They solved it by properly initializing the API key and the function started running correctly.
rohan
9 Sep, 2023, 22:09

when i initiate the client using ENV variables

TypeScript
const client = new sdk.Client()
.setEndpoint(process.env.APPWRITE_FUNCTION_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);

its returning 0 documents

but when i initiate it directly it shows proper result

Drake
10 Sep, 2023, 02:09

Interesting...I didn't know you can call log like that 🧐

Drake
10 Sep, 2023, 02:10

0 documents for what? What do you mean by initiate directly? Is this a function from before 1.4?

rohan
10 Sep, 2023, 09:41

No no it was my mistake I didn't initialize the api key properly

rohan
10 Sep, 2023, 09:42

So it was returning 0 documents

Drake
10 Sep, 2023, 15:47

Ah so you figured it out? This can be marked as solved?

rohan
10 Sep, 2023, 16:32

Yes.. but if the api key is not proper it should throw error

rohan
10 Sep, 2023, 16:33

But instead its still fetching but there are no documents i mean 0

Drake
10 Sep, 2023, 16:49

[SOLVED] function not running properly

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