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
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...