Steve NOriginal post
Flutter Developer
I have a simple function that logs the body text. The body is some simple JSON which I am including in the POST dialog on the appwrite console for executing the function. The log statements return undefined.
module.exports = async function (context) {
try {
console.log(context.req.bodyText);
console.log(context.req.bodyJson);
} catch (error) {
console.error("Error:", error.message);
}
return {};
};
Summary
Issue: The function is logging undefined for context.req.bodyText and context.req.bodyJson when it should be logging the JSON body text.
Solution: Change context.req.bodyText to context.body. This should correctly log the body text.