url<String> The URL to which the request is sent.options<Object>parameter<String> The name of the JSONP query parameter. Defaults to"callback".object<Object> An object to which to attach the JSONP callback. Defaults towindow.key<String> The name of the JSONP callback. Defaults to an automatically generated unique value.
callback<Function(err, data)> A callback function that receives the data.
Loads data from the server using JSONP. Example:
importjsonpfrom'@borodean/jsonp';jsonp('https://jsfiddle.net/echo/jsonp?foo=bar',(err,data)=>{if(err)throwerr;console.log(data);});A version that returns a promise is also available:
importjsonpfrom'@borodean/jsonp/promise';jsonp('https://jsfiddle.net/echo/jsonp?foo=bar').then(data=>console.log(data),err=>console.log(err));npm install @borodean/jsonp
For a browser global version check the dist directory of the installed module or directly download it:
- Production version – 265 bytes, minified and gzipped
- Source map
Promise version:
- Production version – 277 bytes, minified and gzipped
- Source map