Helper to create more safe jsonp response body for koa and other web framework.
npm install jsonp-body --saveconst koa = require('koa');
const { jsonp } = require('jsonp-body');
var app = koa();
app.use(async function () {
  this.set('X-Content-Type-Options', 'nosniff');
  if (this.query.callback) {
    this.set('Content-Type', 'text/javascript');
  } else {
    this.set('Content-Type', 'application/json');
  }
  this.body = jsonp({foo: 'bar'}, this.query.callback);
});Get obj jsonp string response with callback.
- obj: object convert to JSON string
- callback: callback function name
- options: optional for JSON.stringify- limit: length limit for callback, default to512
- replacer: replacer in JSON.stringify(obj, [replacer, [space]])
- space: space in JSON.stringify(obj, [replacer, [space]])
 
- limit: length limit for 
Made with contributors-img.