How can I create a GET api endpoint in nextjs with query param like this /api/users?name=asif

how can I create a GET api endpoint in nextjs with query param like this /api/users?name=asif

how can I capture the value of ‘name’ in code?

I got it.

export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url)
const name = searchParams.get(‘name’)

console.log(name);

return NextResponse.json({name});
}