express-body-parser-json-error

express body-parser json middleware error handler

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
express-body-parser-json-error
000.1.08 years ago8 years agoMinified + gzip package size for express-body-parser-json-error in KB

Readme

express-body-parser-json-error
install
npm install --save express-body-parser-json-error
usage
var express = require('express');
var bodyParser = require('body-parser');
var bodyParserJsonError = require('express-body-parser-json-error');

var app = express();

app.use(bodyParser.json());

app.use(bodyParserJsonError());


app.post('/test', function (req, res) {

    res.json({result: 'ok'});

});

app.listen(8080);

on invalid json body to POST /test, got response
400 Bad Request HTTP/1.1

{
    "error": {
        "message": "Invalid Json Body",
        "code": "invalid_json"
    }
}