Back

[SOLVED] How to use APPWRITE_FUNCTION_EVENT_DATA?

  • 0
  • Web
alpha#trinity1
11 Jul, 2023, 09:12

Hi all, requesting for parameters that can be captured from appwrite server when working with APPWRITE_FUNCTION_EVENT_DATA on client side. Possibly can also assist with document that show structure and content of APPWRITE_FUNCTION_EVENT_DATA.

TL;DR
The user had a question about using `APPWRITE_FUNCTION_EVENT_DATA`. The solution is to stringify and parse the data when sending it from the client to the function. Here's an example code snippet: Client: `await functions.createExeuctions('', JSON.stringify({}));` Function: ```js try { const data = JSON.parse(req.payload); // This is just like the above row const data = JSON.parse(req.variables['APPWRITE_FUNCTION_EVENT_DATA']); } catch (e) { // Data is not json parsable. } ``` The user also requested assistance with capturing parameters and a document showing the
Binyamin
11 Jul, 2023, 13:11

APPWRITE_FUNCTION_EVENT_DATA or req.payload contains the data being sent to the function.

The value is string.

So when you send it you should stringify it, and parse it

Client

TypeScript
await functions.createExeuctions('',JSON.stringify({}));

Function

TypeScript
try {
const data = JSON.parse(req.payload);
// This is just like the above row
const data = JSON.parse(req.variables['APPWRITE_FUNCTION_EVENT_DATA']);
} catch (e) {
  // Data is not json parsable.
}
alpha#trinity1
12 Jul, 2023, 12:10

thank you

alpha#trinity1
12 Jul, 2023, 12:10

thank you

Drake
13 Jul, 2023, 03:05
Drake
13 Jul, 2023, 03:06

[SOLVED] How to use APPWRITE_FUNCTION_EVENT_DATA?

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