universal-jsonp
v0.6.5
Published
A universal JSONP utilities.
Downloads
99
Readme
universal-jsonp
jsonp like standard Fetch API
Install
$ npm install universal-jsonp --save
Usage
import jsonp from 'universal-jsonp';
jsonp('/users.jsonp')
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json', json)
}).catch(function(err) {
console.log('parsing failed', err)
});
APIS
jsonp(url, options)
- url: Required, String, jsonp url
- options: Optional, Object, options attributes:
- timeout: Number, default 5000ms
- jsonpCallback: String, default
callback
- jsonpCallbackFunctionName: String, default randomly generated