Rank 3: Container
I need help about function, always failed when execute
How can I debug the function?
Votes
0
Replies
15
Participants
Unknown
Messages
16
Rank 3: Container
I need help about function, always failed when execute
How can I debug the function?
Rank 3: Container
This my code
I'm not sure if your path in the appwrite.json is correct.
Rank 3: Container
My appwrite.json place on root of dir
ooh my bad, i thought it was already inside functions directory.
whats the appwrite version? cloud?
Rank 3: Container
Yeah, cloud version
Hmm, the syntax is for 1.4x, Cloud isn't on 1.4x yet.
Rank 3: Container
Owh, my bad
Rank 3: Container
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.
context, req or res objects locally.env or 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, })Rank 3: Container
Oh it's work
Rank 3: Container
So it's not posible if I want to run function locally, or how can I create object like Appwrite function send?
Rank 3: Container
This I try to create the object
payload and variables won't be functions. A Dictionary I'd assume.
[SOLVED] debug the Python Function