Back

[SOLVED] function req.body problem

  • 0
  • Functions
ianmont
26 Oct, 2023, 01:15

Im starting a function, and when I try to parse the req.body it just doesnt work

I attached some images of my code

For example if I log(bodyParsed.userId) is just undefined

Am i doing something wrong?

TL;DR
The user had a problem with parsing the req.body in their code. They managed to solve the error by deleting node-appwrite from the dependencies in the package.json and commenting out the import statement for 'node-appwrite'. They mentioned that when these were present, it was impossible to parse the req.body and the function stopped working with a 500 error. It is unclear what caused this issue. The user also mentioned that they are using "node-appwrite": "^9.0.0".
Drake
26 Oct, 2023, 02:23

Perhaps it's already parsed so you don't need to parse it again

ianmont
26 Oct, 2023, 22:07

appwrite automatically parses the req.body?

ianmont
26 Oct, 2023, 23:10

I know the error seems very dumb, but it gets very strange...

When I delete node-appwrite from the dependencies on the package.json and comment the import { Client } from 'node-appwrite', out of nowhere everything works, I can extract the userId from the req.body and the log(bodyParsed) shows as a JSON

when the node-appwrite from the package.json and import { Client } from 'node-appwrite' is present in the code it is impossible to parse the req.body, It remains as a string and recently the entire function stopped working for no reason with an error of:

Multiple internal curl errors has occurred within the executor! Error Number: 111. Error Msg: Connection refused\nError Code: 500

What could cause it?

Im using "node-appwrite": "^9.0.0", i will attach a photo of my package.json, my code and the new error that appears in the console in case that helps...

Drake
27 Oct, 2023, 00:58

how are you executing the function?

ianmont
27 Oct, 2023, 01:25

Do you mean where I am running it from? I am using the appwrite interface, I will attach an image

Drake
27 Oct, 2023, 01:25

This is the exact same both times you executed?

ianmont
27 Oct, 2023, 17:52

I managed to solve the error, I tried many things and I no longer know which one worked

but now it works, thanks steven

ianmont
27 Oct, 2023, 17:53

[SOLVED] function req.body problem

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