NextResponse: send empty body with status 204
Answered
Wookie posted this in #help-forum
WookieOP
I basically wanna send an empty response with status code 204, what would be the way to do this using the app directory and route handlers?
Answered by Wookie
return new NextResponse(undefined, { status: 204 })This does seem to work somewhat but don't know if it's the right way to do it
11 Replies
WookieOP
return new NextResponse(undefined, { status: 204 })This does seem to work somewhat but don't know if it's the right way to do it
Answer
@ᴉuɐpɹɐɐ It should be `NextResponse`
WookieOP
oh yea sorry that is it my bad, ok well then it is the right way to do it it seems
typo woops
well can consider this closed basically but would be open to any other opinions
might not even need this anymore with the new react server components thing
@Wookie I basically wanna send an empty response with status code 204, what would be the way to do this using the app directory and route handlers?
i would use
return new Response(null, { status: 204 }), but yeah these options are goodsince you don't care about the response body, can put anything in there
Asian black bear
I suggest against
undefined since it's not valid JSONSo send
null instead.WookieOP
ok thanks a lot guys