Bun Request.json() failed to parse in API Route.
Unanswered
wolfishy posted this in #help-forum
wolfishyOP
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?
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' }));
}
export async function POST(request: Request) {
const { data } = await request.json();
console.log(data);
return new Response(JSON.stringify({ message: 'success' }));
}
@wolfishy 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?
ts
export async function POST(request: Request) {
const { data } = await request.json()
console.log(s);
return Response.json(JSON.stringify({ message: 'success' }));
}
thats prob a bun issue then... bun doesn't work well with nextjs app dir
@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' }));
}
wolfishyOP
no i tried to see under the console log, so doesnt matter what response
@riský thats prob a bun issue then... bun doesn't work well with nextjs app dir
wolfishyOP
and yeah I think you right.
cause no matter what when I run with
--bun it just doesn't work