JSON.parse(event.body) wont work and omitting the parse cant access the objects of the boddy

I am creating Netlify function and I want to access the event.body objects (especially the event.body.mode/requestBody.mode) but console.log gives me undefined.

exports.handler = async function (event) {

    const requestBody = event.body;

    console.log(requestBody);
    console.log(requestBody.mode);

    let variableX = requestBody.mode;

    return {
        headers: {
            "content-type": "application/json",
          },
      statusCode: 200,
 
      body: JSON.stringify({"message":variableX}),
    };
  };

Here is the Function log:

Aug 4, 09:28:19 PM: 4870e164 INFO   {"eventName":"shippingrates.fetch","mode":"Live"}
Aug 4, 09:28:19 PM: 4870e164 INFO   undefined

I have tried to JSON.parse the event.body but it returns an error. Not parsing works. I also tried requestBody['mode'] but still no luck.

Are you sending any body to the function?

I found a solution already. It still needs to parse the event.body

JSON.parse(event.body) is returning an error.

But the following works:

const requestBody = event.body;
console.log(JSON.parse(requestBody).mode);