0.1.2 • Published 5 years ago

sync-jsonp v0.1.2

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

sync-jsonp

安装

npm install sync-jsonp --save

使用

import syncJsonp from 'sync-jsonp'

api

syncJsonp(url, data, opts): Promise

  • url (string) url to fetch
  • data (object) send param, optional
  • 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)

example

import syncJsonp from 'sync-jsonp';

syncJsonp('http://hostname.com/path/to/api').then((data) => {
  console.log(data);
});

syncJsonp('http://hostname.com/path/to/api', {
  t: +new Date()
}).then((data) => {
  console.log(data);
});

syncJsonp('http://hostname.com/path/to/api', undefined, {
  timeout: 2000
}).then((data) => {
  console.log(data);
});
0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago