module.exports = (request, response, nextMethod) => { let data = [] request.on("data", dataChunk => { data.push(dataChunk) }) request.on("end", () => { request.body = Buffer.concat(data).toString() if (request.headers["content-type"] === "application/json"){ request.body = JSON.parse(request.body); } nextMethod(request, response) }) }