Rank 2: Process
This is the code to print all value
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 2: Process
This is the code to print all value
Rank 2: Process
And the first img is the output it gave to me
Admin
req.bodyRaw is a string so when you stringify that, jsonBody results in a nested string. When you parse that, parsedJsonbody becaomes a string
Admin
please try using req.body.hi
Rank 2: Process
Okay, let me try it and get back to you
As an aside, I could not get
req.body.whateverto work. I had to do
let parsedBodyRaw = JSON.parse(req.bodyRaw);// And then I could access 'whatever' viaparsedBodyRaw.whateverRank 2: Process
Okay will try that out
Rank 2: Process
Still didn't work, let me try the other guy suggestion, and see how it goes
Rank 2: Process
💯💯💯💯💯❤️❤️❤️❤️❤️❤️
Thanks so much, It works
I have been debugging this for a very long time, and you kinda make it look easy.
I appreciate your time ❤️
Rank 2: Process
Hi, so I have gotten it to work, thanks for joining in to debug this with me I really appreciate this ❤️❤️❤️❤️❤️❤️❤️❤️,
💯 To appwrite once again
Rank 2: Process
Can't get body data in the req module for node.js
Yep, I probably spent a good 30 minutes banging my head against the wall before figuring that out. Not entirely sure why the req.body route doesn't work
Rank 2: Process
Yer, me too, made me question my field of study 😅. Not really sure if I would have guess this if you haven't said so.
Rank 2: Process
Maybe the appwrite team need to look more into this.
Yeah, I would be curious to see if it's a "we're the dumb ones" or if there's actually a bug in the req module
Admin
Not entirely sure why the
req.bodyroute doesn't work
what do you mean?
At risk of you highlighting something dumb that I've overlooked (as has been my habit the past couple days)..
export default async ({ req, res, log, error }) => { // these would just return nothing/empty string log(req.body.blah) log(JSON.stringify(req.body.blah)) // these worked const parsedBodyRaw = JSON.parse(req.bodyRaw); log(parsedBodyRaw.blah) log(JSON.stringify(parsedBodyRaw.blah))}Admin
what are you sending to the function? how are you executing your function? what is req.body?
Executing via manual execution in Appwrite Console as well as REST
Sending:
{ "myKey": "myValue" }Function Code
export default async ({ req, res, log, error }) => { // req.body log("req.body"); log(req.body);
log("req.body.myKey"); log(req.body.myKey);
log("JSON.stringify(req.body.myKey)"); log(JSON.stringify(req.body.myKey));
// req.bodyRaw let parsedBodyRaw = JSON.parse(req.bodyRaw); log("parsedBodyRaw"); log(parsedBodyRaw);
log("parsedBodyRaw.myKey"); log(parsedBodyRaw.myKey);
log("JSON.stringify(parsedBodyRaw.myKey)"); log(JSON.stringify(parsedBodyRaw.myKey));Output
req.body
{ "myKey": "myValue" }
req.body.myKey
undefined
JSON.stringify(req.body.myKey)
undefined
------------
parsedBodyRaw
{"myKey":"myValue"}
parsedBodyRaw.myKey
myValue
JSON.stringify(parsedBodyRaw.myKey)
"myValue"
Did I find a bug or am I big dumb idiot of the day? 🤞 😨
Admin
so it looks like req.body will only be parsed if the header specifies the content type is application/json:
Would you look at that...I might be biased but I would assume that JSON would be the default, especially with how the documentation and helper formats are all JSON
Admin
ya....that would make sense...
Rank 2: Process
Wow, didn't knew that
Rank 2: Process
Taught so too
Rank 2: Process
[SOLVED] Can't get body data in the req module for node.js