Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Only try to parse body if method is not GET
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Jan 22, 2017
1 parent 6960f7f commit addf5aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit addf5aa

Please sign in to comment.