Support Promise For JSONP.
npm install flex-jsonp --save
flexJsonp({
url: 'http://suggestion.baidu.com/su',
params: {
wd: keywords,
p: 3,
t: new Date().getTime()
},
callbackParam: 'cb'
}).then(function (res) {
console.log(res);
}).catch(function (err) {
console.log(err);
});
names | type | default | explain |
---|---|---|---|
url | string | '' | The url requested by JSONP |
params | object | {} | Request parameters |
timeout | number | 0 | Request timeout setting |
callbackParam | string | 'cb' | JSONP callback function parameter name |
callback | string | 'callback'+${seed} | JSONP callback function name |
MIT