Meant for use across the browser and node, this simple module will use jsonp if instantiated in a browser and axios if in node. In both cases a promise will be returned.
Execute a GET request using JSONP if in a browser environment.
Kind: inner method of jsonp-fallback
Returns: Promise
- Contains the data or error if one was encountered
Param | Type | Description |
---|---|---|
url | String |
A resource that can be accessed using JSONP |
data | Object |
Parameters to be encoded for the querystring |
params | Object |
A parameters object that will be passed through to JSONP if it is used. Note: this module defaults the JSONP timeout value to 15 seconds instead of 60 if it is not specified. |
Example
const jsonpFallback = require("jsonp-fallback")
jsonpFallback("https://www.omdbapi.com/", {"i": "tt3397884"})
.then(data => {
console.log(data)
})
.catch(console.error)