Skip to content

Commit

Permalink
fixup! apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
biniam committed Feb 1, 2018
1 parent df338ad commit f90abf2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/rest/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ type HttpError = HttpErrors.HttpError;
// tslint:disable-next-line:no-any
type MaybeBody = any | undefined;

const jsonBodyAsync = promisify(require('body/json'));
const parseJsonBody: (req: ServerRequest) => Promise<MaybeBody> = promisify(
require('body/json'),
);

/**
* Get the content-type header value from the request
Expand Down Expand Up @@ -67,7 +69,7 @@ function loadRequestBodyIfNeeded(
return Promise.reject(err);
}

return jsonBodyAsync(request).catch((err: HttpError) => {
return parseJsonBody(request).catch((err: HttpError) => {
err.statusCode = 400;
return Promise.reject(err);
});
Expand Down

0 comments on commit f90abf2

Please sign in to comment.