Back

Capturing Event Data in Functions Triggered by Account Delete Events

  • 0
  • Functions
DerrickML
21 Dec, 2023, 06:40

Hello Beautiful People,

I'm working on a feature where I need to execute certain actions in a function when a user account is deleted. This function would ideally be triggered by the account deletion event in Appwrite.

My key question is: Does Appwrite pass any specific data (like userID or other identifiers) to the function when it is triggered by an account deletion event? If so, how can I capture and utilize this data within my function?

I'm specifically looking to understand:

  1. The nature of the data passed to the function on such an event.
  2. The method or syntax for accessing this data within the function. Any guidance, code snippets, or pointers to relevant documentation would be immensely helpful.

Thank you for your assistance!

TL;DR
The user wants to know how to capture specific data when a user account is deleted in Appwrite. They are looking for information on the data passed to the function and how to access it. They have found the solution to access the user ID through `JSON.stringify(req.body)`.
DerrickML
21 Dec, 2023, 10:14

Got the solution. The users id can be accessed through the request object passed by the event through JSON.stringify(req.body)

Drake
21 Dec, 2023, 17:15

yes, the body always contains the payload of the event. so, if you have a function that triggers on document update, the body would be the updated document.

In addition, the headers have some additional info too, such as who triggered the function: https://appwrite.io/docs/products/functions/development#headers

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