I need help about function, always failed when execute
How can I debug the function?
This my code
I'm not sure if your path in the appwrite.json is correct.
My appwrite.json place on root of dir
ooh my bad, i thought it was already inside functions directory.
whats the appwrite version? cloud?
Yeah, cloud version
Hmm, the syntax is for 1.4x, Cloud isn't on 1.4x yet.
Owh, my bad
Do you know how can I debug my code is work or not locally, before I deploy it?
You could, but there are a few gotchas.
- You wouldn't have access to the
context,reqorresobjects locally. - You will have to use
envor hardcode your keys / variables & use the function as a normal method call.
Also, this is the pre-1.4x syntax, example function:
import random
def main(req, res):
print("Hello, Logs!")
payload = req.payload or 'No payload provided. Add custom data when executing function.'
secretKey = req.variables.get(
'SECRET_KEY',
'SECRET_KEY variable not found. You can set it in Function settings.'
)
randomNumber = random.random()
trigger = req.variables['APPWRITE_FUNCTION_TRIGGER']
return res.json({
'message': 'Hello from Appwrite!',
'payload': payload,
'secretKey': secretKey,
'randomNumber': randomNumber,
'trigger': trigger,
})
Oh it's work
So it's not posible if I want to run function locally, or how can I create object like Appwrite function send?
This I try to create the object
payload and variables won't be functions. A Dictionary I'd assume.
[SOLVED] debug the Python Function
Recommended threads
- Functions in cloud console not works
please advise as all of my runing functions on Appwrite console was working before , but now it give this error [Invalid `headers` param: Value must be a valid...
- [SOLVED] Production down - createExecuti...
Hey, Since 1.9.6 rollout in fra (~17:00 UTC, 14 Aug), POST /v1/functions/{functionId}/executions returns a 400 whenever the body includes an empty headers ob...
- [SOLVED] CreateRow is doing ListRows on ...
### setup ``` appwrite 1.9.5 self-hosted bun 1.3 node-appwrite 27.1.0 ``` ### issue Im running a function on a self hosted 1.9.5 with "node-appwrite": "^27.1.0...