Next.js Discord

Discord Forum

Unexpected end of JSON input

Answered
oguisantosilva posted this in #help-forum
Open in Discord
I'm using postman to send a GET request with data in the body of the request, the problem is when i try to console.log the data in the body it says that de body is empty.

Can someone help?
Answered by riský
you can use POST however
View full answer

11 Replies

import { NextRequest, NextResponse } from "next/server"

export async function GET(request: Request, response: Response) {
    const { data } = await request.json()

    return NextResponse.json(data)
}
you cant have a body in GET request
you can use POST however
Answer
using GET for login interaction is bad as it could lead to leaking sensitive information
omg im so dumb
thanks
@oguisantosilva omg im so dumb
hey now don't be so hard on yourself! we all have those moments
i was coding for too long
3AM haha