Promise based jsonp
$ npm install jsonp_p
import jsonpPromise from 'jsonp_p'
jsonpPromise({
url: 'http://jsfiddle.net/echo/jsonp/',
params: {
name: 'jsonp_p',
version: '0.0.1'
},
callback: 'jsonpPromise'
}).then( data => {
console.log(data)
//{name: 'jsonp_p',version: '0.0.1'}
})
request url
query string defaultencodeURI
callback name
jsonp_p depends on a native ES6 Promise implementation to be supported. If your environment doesn't support ES6 Promises, you can polyfill.