Back

Function undefined req.bodyText

  • 0
  • Self Hosted
  • Cloud
Steve N
21 Aug, 2024, 14:28

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);

TypeScript
} catch (error) {
    
    console.error("Error:", error.message);  
}

return {};

};

TL;DR
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.
Kenny
21 Aug, 2024, 14:56

Can you send a picture of the dialog?

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