bin/middleware.js
function parseBody(req) {
    return extractBody(req)
        .then(() => {
            if (req.body && typeof req.body === 'object') return req.body;
            try {
                return JSON.parse(req.body);
            } catch (err) {
                throw Error('Unexpected body format received. Expected application/json, received: ' + req.body);
            }
        });
}
function parseBody(req) {
    return extractBody(req)
        .then(() => {
            if (req.body && typeof req.body === 'object') return req.body;
            try {
                return JSON.parse(req.body);
            } catch (err) {
                throw Error('Unexpected body format received. Expected application/json, received: ' + req.body);
            }
        });
}
function parseBody ( req ) { return extractBody ( req ) . then ( ( ) => { if ( req . body && typeof req . body === 'object' ) return req . body ; try { return JSON . parse ( req . body ) ; } catch ( err ) { throw Error ( 'Unexpected body format received. Expected application/json, received: ' + req . body ) ; } } ) ; }
Parse the response body.
@param {Object} req
@returns {Promise}
Parse the response body .