node package manager

superagent-jsonpx

superagent-jsonpx

npm version Coverage Status

Installation

Install for node.js or browserify using npm:

$ npm install --save-dev superagent-jsonpx

Example

var request = require('superagent');
var jsonp = require('superagent-jsonpx');
 
var options = { timeout: 3000, callbackKey: 'cb' };
 
request.get(uri)
  .use(jsonp(options))
  .end(function (err, res) {
    if (!err && res.body) {
      // request success 
      console.log(res.body);
    } else {
      // request timeout (or error) 
    }
  });

Options

timeout

If there is no response after a timeout, it will determine that an error has occurred.

  • default: 1000ms

callbackKey

This will change the default query string callback parameter.

  • default: callback