Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including jsendp with all npm packages installed. Try it out:

var jsendp = require("jsendp")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

jsendp v2.1.0

JSend middleware (with JSON-P) for Connect and Express.


jsendp is middleware to add:

  • res.success
  • res.error

in Express and Connect apps. It works just like res.json and res.jsonp but wraps your response body in the JSend specification.

This was heavily inspired by jsender and express-jsend, however jsendp uses res.jsonp by default and lets you also special the HTTP status code.


npm install jsendp --save


Add jsendp like you would any other middleware.

const express = require('express')
const jsendp = require('jsendp')

const app = express()


app.get('/', function (req, res, next) {
    message: 'Hi, Mom!'


JSON-P is enabled by default, though you can disable it (reverting to res.json) by passing an options object to the middleware:

const express = require('express')
const jsendp = require('jsendp')

app.use(jsendp({ jsonp: false }))


jsendp adds the following methods to the res object:

res.success({statusCode, data, message}){statusCode, data, message})
res.error({statusCode, data, message})


Released under the MIT License:

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free