
Iam new to functions and i want to execute a function that triggers when the payment is made on adapty . The function should update the a attribute in user database and also there should be another function that changes the attribute again after a specific time period I have copied and changed the code from the internet , is the code correct The errror that shows in appwrite is: TypeError: userFunction is not a function at /usr/local/src/server.js:68:19 at processTicksAndRejections (node:internal/process/task_queues:96:5)
And also is there any way to test the functions locally using postman

When using Appwrite function - in current versions - it's vital to keep the Appwrite main exported
function.
In your case its seems like you're using the Appwrite node
function.
For that the only exported function should be something like this
const sdk = require("node-appwrite");
module.exports = async function (req, res) {
const client = new sdk.Client();
const database = new sdk.Databases(client);
// Other modules
// Function code.
res.json({'success': true});
};
As Appwrite will always try to load on function with this signature
module.exports = async function (req, res) {}

You can use Appwrite CLI To generate your functions:
https://appwrite.io/docs/command-line
appwrite init function
will create your function with all necessary files then use appwrite deploy function
to upload the changes to appwrite (make sure to select the function pressing the space bar)

To execute a function from postman you should send a POST request to /v1/functions/{functionId}/executions
with the functionId
param

Make sure your function have the right permission to be executed

I changed the code to this, but now it is showing error as:

An internal curl error has occurred within the executor! Error Msg: Operation timed out

@Binyamin What should i put in the place of endpoint

Are you using appwrite cloud?

Yes??

sorry iam not using appwrite cloud , iam using the normal functions in appwrite

Have you set the project and api and this is just an example?

Thank you for helping out, i resolved the issues

Can we trigger the function when a payment is made on adapty?

To be able to that You'll need to have a webhook towards your function. In the next Appwrite function release it will be an option, for now you'll need to use something like this https://github.com/Meldiron/railway-webhook-proxy

So even if i set webhook endpoint to the appwrite function , it wont be executed. I have to set the webook proxy using railway?

For now, yes.
Because as of now Appwrite function require you to send project ID and this part can't be done with URL variables.
Check this - in the Future possibilities
section.
https://github.com/appwrite/appwrite/discussions/5016

Ok thank you very much<:appwriteheart2:1073243188954935387>

[SOLVED] Error in function execution
Recommended threads
- Queries Length Error.
Hi All, I am having a issues across my app with how i am getting data, and just wanted to check if this was an issues with the new changes on appwrite over the...
- My projects archived. Did not see the up...
Kindly restore project for me: 67680a26001bdf36beb8 You can delete: 678c96ba00305f78bb13 675d05040004853fb43f
- My projects archived. Did not see the up...
Kindly restore these two projects for me 66d6f4270037aafe3c39 and 663fdf520017d2d0f4e8 You can delete 66887997000e2c5b7e49
