From addf5aa4d31cc534c51be87e34bee834a2abab40 Mon Sep 17 00:00:00 2001 From: onbjerg Date: Sun, 22 Jan 2017 12:21:31 +0100 Subject: [PATCH] Only try to parse body if method is not GET --- index.js | 12 +++++++----- package.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index c72f348..cbae484 100644 --- a/index.js +++ b/index.js @@ -15,11 +15,13 @@ function visualize (fn, log = 'dev') { const dateString = `${chalk.grey(start.toLocaleTimeString())}` console.log(`> #${requestIndex} ${chalk.bold(req.method)} ${req.url}\t\t${dateString}`) - try { - const parsedJson = await json(req) - jsome(parsedJson) - } catch (err) { - console.log(`JSON body could not be parsed: ${err.message}`) + if (req.method !== 'GET') { + try { + const parsedJson = await json(req) + jsome(parsedJson) + } catch (err) { + console.log(`JSON body could not be parsed: ${err.message}`) + } } res.once('finish', () => { diff --git a/package.json b/package.json index 44c371f..8edc818 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "micro-visualize", - "version": "1.0.2", + "version": "1.0.3", "description": "Visualize requests in micro", "main": "./dist/index.js", "repository": "https://github.com/onbjerg/micro-visualize",