Why is req.body undefined in Next.js? [duplicate]

I am logging out request.body and it says that it is undefined.

Here is the code of api/generateFlashcards/page.ts

export default async function POST(request: NextApiRequest) {
  const data = request.body;
  console.log(data)
}

And Here is where I am trying to fetch it. (description is a string just in case):

fetch('/api/generateFlashcards', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({description}),  
}).then(res => {
    console.log(res);
})

I tried changing the type of request to request: Request. Also, tried request.json() which gave an error:

TypeError: request.json is not a function
    at POST (./app/api/generateFlashcards/page.ts:39:25)
    at stringify (<anonymous>)

I tried to look at other’s solutions but they didn’t work.