Skip to content
Permalink
Browse files

add json support

  • Loading branch information...
galvez committed Apr 28, 2019
1 parent c2b55c8 commit 66e4ee75359360f1182f7424d6e6754fbcbf97cd
Showing with 9 additions and 1 deletion.
  1. +7 −0 api.js
  2. +2 −1 package.json
7 api.js
@@ -1,8 +1,15 @@
import { json } from 'body-parser'

export default [
{
path: '/api/ping',
handler(req, res, next) {
res.end(`API pong at ${new Date().getTime()}`)
}
},
json(),
(req, res, next) => {
res.json = (obj) => res.write(JSON.stringify(obj))
next()
}
]
@@ -18,6 +18,7 @@
"nuxt": "^2.6.3"
},
"dependencies": {
"@nuxt/http": "^0.1.1"
"@nuxt/http": "^0.1.1",
"body-parser": "^1.19.0"
}
}

0 comments on commit 66e4ee7

Please sign in to comment.
You can’t perform that action at this time.