the key value seems to be received as a query string instead of json.
Summary
The user was experiencing an issue with res.body not being in JSON format. Another user suggested that the issue may be caused by using form data instead of JSON. The solution was to use x-www-form-url-encoded to get JSON data in the request body. One user also mentioned that in Postman, using raw and inputting the actual JSON object will work. The problem with the user's code was that it was receiving the key value as a query string instead of JSON. The solution was to modify the code to parse the JSON payload correctly.
D5
Moderator
Sep 1, 2023, 19:51
Aren't you using stringfy?
SenZi
Rank 3: Container
Sep 1, 2023, 19:57
yea but it shouldn't make it a query string right with the =
Drake
Sep 1, 2023, 21:06
nope. you see you have x-www-form-url-encoded. that's the result when you do that
SenZi
Rank 3: Container
Sep 1, 2023, 21:07
what should it be then?
Drake
Sep 1, 2023, 21:26
in Postman you have to use raw and put in the actual JSON object
SenZi
Rank 3: Container
Sep 1, 2023, 21:59
Ohk Got It, That fixed it and it works fine. When i used to work with express js before i remember using the x-www-form-url-encoded to get json data in the request body.
VincentGe
Sep 1, 2023, 22:07
[Solved] res.body isn't json
Drake
Sep 1, 2023, 22:10
nope that's form data which is not json. express may have automatically been parsing the form data for you