Back

[SOLVED] Can't Access Data in the response payload when Function is trigger

  • 0
  • Flutter
  • Cloud
Zionnite
29 Feb, 2024, 01:52

i want to access some data when a user create a document and also when a user delete a document

when I log out this output log({"eventTriggered": JSON.stringify(req.body)}); i get the following

TypeScript

so now when i try to access the individual object let says postType it log out empty as though nothing is inside,

so i decided to use JSON.parse(req.body) i got the following errors

TypeScript
    at JSON.parse (<anonymous>)
    at Module.default (file:///usr/local/server/src/function/src/main.js:24:28)
    at execute (/usr/local/server/src/server.js:141:48)
    at async /usr/local/server/src/server.js:158:13```

Please, what i'm i doing wrong??
TL;DR
Data access issue in response payload when triggering a function. Developer swapped `JSON.stringify(req.body)` for `JSON.parse(req.bodyRaw)` to fix the problem of accessing data.
Steven
29 Feb, 2024, 01:54

How are you trying to access the data?

Zionnite
29 Feb, 2024, 01:58

i have resolved it i change the JSON.stringify(req.body) to JSON.parse(req.bodyRaw) and it fixed it

Zionnite
29 Feb, 2024, 01:59

[SOLVED] Can't Access Data in the response payload when Function is trigger

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