Hello everyone,
I recently started using the Appwrite cloud service and was experimenting with its functions feature.
Previously, I used AWS Lambda, and now I want to switch to Appwrite.
In AWS Lambda, you can trigger a function by sending an HTTP request to its function URL. In Appwrite, it seems we can achieve this by sending a POST request to the following URL: 'https://cloud.appwrite.io/v1/v1/functions/functionId/executions'.
However, I'm facing an issue when I try to invoke a function I created by sending a POST request using a tool like Postman. The error message I'm encountering is:
TypeError: Cannot set properties of undefined (setting 'functions')
at module.exports (/usr/code-start/index.js:19:20)
at /usr/local/src/server.js:68:19
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The function works perfectly fine when I manually trigger it from the Appwrite console.
Also, I'm sending the request with all the necessary headers, including X-Appwrite-Project, Content-Type, and X-Appwrite-Key, along with a correct JSON body.
Here is the demo function code I am using:
module.exports = async (req, res) => {
let options = JSON.parse(req.payload);
res.json(options);
};
Could someone please assist me in resolving this issue? Your help would be greatly appreciated.
Thank you.