Next.js Discord

Discord Forum

Bun Request.json() failed to parse in API Route.

Unanswered
wolfishy posted this in #help-forum
Open in Discord
I start the dev server with Bun and the json failed to parse.
and when I run it with Node, I get no error at all.

I tried with postman, fetch, axios it has same results.
am I doing wrong?

export async function POST(request: Request) {
  const { data } = await request.json()
  console.log(s);

  return Response.json(JSON.stringify({ message: 'success' }));
}

5 Replies

Morelet’s Crocodile
Try this:

export async function POST(request: Request) {
const { data } = await request.json();
console.log(data);
return new Response(JSON.stringify({ message: 'success' }));
}
cause no matter what when I run with --bun it just doesn't work