Route handler 500 internal error
Unanswered
Kokoni posted this in #help-forum
KokoniOP
14 Replies
@Kokoni Click to see attachment
export async function GET() {
try {
await connect();
return NextResponse.json({ id: "hello" });
} catch (err) {
return NextResponse.json({ error: "something went wrong" });
}
}the route handler
@Kokoni it needs to have a try catch?
try/catch in async/await is the better syntax, not a .then().catch()
KokoniOP
but
in your above work, connect() might not return yet when you return { id: hello } although it is not related to the error
@joulev try/catch in async/await is the better syntax, not a .then().catch()
KokoniOP
I'm trying to get the params
it doesn't work
@Kokoni Click to see attachment
GET(req, { params })it is the second parameter
KokoniOP
oh, tysm, I'm new in the app dir
tysm