Skip to content

Commit

Permalink
report error when the body is empty, closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Jun 24, 2021
1 parent 91b62aa commit 6a65368
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function getParseBody<P extends object = Record<string, never>>(a

return async (cxt: KoaContext<P>): Promise<void> => {
const str = await jsonBodyStr(cxt)
const data = str && parse(str)
const data = str !== undefined && parse(str)
if (data === undefined) {
cxt.status = 400
cxt.body = {error: parse.message}
Expand Down

0 comments on commit 6a65368

Please sign in to comment.