Skip to content

Meant for use in both 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.

Notifications You must be signed in to change notification settings

scytalezero/jsonp-fallback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonp-fallback

build status

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.

jsonp-fallback~exports(url, data, params) ⇒ Promise

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)

About

Meant for use in both 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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published