jsonp like standard Fetch API
$ npm install universal-jsonp --save
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)
});
- url: Required, String, jsonp url
- options: Optional, Object, options attributes:
- timeout: Number, default 5000ms
- jsonpCallback: String, default
callback
- jsonpCallbackFunctionName: String, default randomly generated