@wii/jsonp
TypeScript icon, indicating that this package has built-in type declarations

2.12.2 • Public • Published

JSONP

A sane JSONP implementation

Install

npm i @wii/jsonp

API

jsonp(url, opts, fn)

  • url (String) url to fetch
  • opts (Object), optional
    • param (String) name of the query string parameter to specify the callback (defaults to callback)
    • timeout (Number) how long after a timeout error is emitted. 0 to disable (defaults to 60000)
    • prefix (String) prefix for the global callback functions that handle jsonp responses (defaults to __jp)
    • name (String) name of the global callback functions that handle jsonp responses (defaults to prefix + incremented counter)
  • fn callback

The callback is called with err, data parameters.

If it times out, the err will be an Error object whose message is Timeout.

Returns a function that, when called, will cancel the in-progress jsonp request (fn won't be called).

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @wii/jsonp

      Weekly Downloads

      1

      Version

      2.12.2

      License

      MIT

      Unpacked Size

      7.88 kB

      Total Files

      6

      Last publish

      Collaborators

      • leo_
      • jerryjchen
      • chanceyliu
      • kagawa
      • jasonngao
      • qinmudi
      • wenyan0202
      • wongjorie