diff --git a/src/middleware/node/get-payload.ts b/src/middleware/node/get-payload.ts index 37eb79ad..cead47c0 100644 --- a/src/middleware/node/get-payload.ts +++ b/src/middleware/node/get-payload.ts @@ -12,18 +12,16 @@ import AggregateError from "aggregate-error"; type IncomingMessage = any; export function getPayload(request: IncomingMessage): Promise { - if (request.body) { - if ( - typeof request.body === "object" && - "rawBody" in request && - request.rawBody instanceof Buffer - ) { - // The body is already an Object and rawBody is a Buffer (e.g. GCF) - return Promise.resolve(request.rawBody.toString("utf8")); - } else { - // The body is a String (e.g. Lambda) - return Promise.resolve(request.body); - } + if ( + typeof request.body === "object" && + "rawBody" in request && + request.rawBody instanceof Buffer + ) { + // The body is already an Object and rawBody is a Buffer (e.g. GCF) + return Promise.resolve(request.rawBody.toString("utf8")); + } else if (typeof request.body === "string") { + // The body is a String (e.g. Lambda) + return Promise.resolve(request.body); } // We need to load the payload from the request (normal case of Node.js server)