I am running a function
const payload = req.body;
const userId = payload.userId;
const secretToken = payload.secretToken;
if (!userId || !secretToken) {
return res.json({
status: "failed",
message: "Invalid Parameters",
body: JSON.stringify(payload)
});
}
the key value seems to be received as a query string instead of json.
Aren't you using stringfy?
yea but it shouldn't make it a query string right with the =
nope. you see you have x-www-form-url-encoded. that's the result when you do that
what should it be then?
in Postman you have to use raw and put in the actual JSON object
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.
[Solved] res.body isn't json
nope that's form data which is not json. express may have automatically been parsing the form data for you
Recommended threads
- I can't UNPAUSE my project with the free...
I received an email notifying me that my project had been paused due to inactivity, and the email included a link to "Restore project." However, that button red...
- Error trying to deploy functions from CL...
✗ Error • on-auth-create (6a00b2ab000c9ce2949b) • Server Error ✗ Error: No functions were pushed. Prject ID: 69ffe0270033a4ac420a
- Intermittent Deploy and Execution Errors...
Project: project-fra-658e2f5f4ba30df91177 Function ID: 69bde006001c56757f49 **Several execution errors with:** Timed out waiting for runtime.\nError Code: 400...