diff --git a/packages/rest/src/parser.ts b/packages/rest/src/parser.ts index e4c82f6b5e65..b91149f8b54b 100644 --- a/packages/rest/src/parser.ts +++ b/packages/rest/src/parser.ts @@ -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 = promisify( + require('json/body'), +); /** * Get the content-type header value from the request @@ -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); });