Registry / testing / jsonp-retry

jsonp-retry

JSON →
library1.0.3jsnpmunverified

A JSONP library with built-in retry and localStorage caching. Version 1.0.3 (latest). Provides configurable retries on timeout, backup URLs, and optional automatic storage/retrieval of responses from localStorage with a custom validation function. Designed for browser environments where JSONP is needed (e.g., cross-domain requests). Simple API supporting callback and Promise patterns. Not actively maintained (no recent commits). Minimal dependencies.

npm install jsonp-retry
INSTALL
IMPORT
SIG · JSONP-RETRY
J
jsonp-retry
testingjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import jsonp from 'jsonp-retry'
const jsonp = require('jsonp-retry')
Package exports a default function; CommonJS require works too.
jsonp
const jsonp = require('jsonp-retry')
import { jsonp } from 'jsonp-retry'
There is no named export 'jsonp'; use default import.
default
jsonp(url, opts, (err, data) => {})
jsonp(url, opts).then(data => {}).catch(err => {}) (Promise usage is fine but note that the callback-style is default; cannot use both at same time)
The function accepts an optional callback; if omitted, returns a Promise (if Promise is available).

Basic usage with callback, timeout, retry, and localStorage caching with data validation.

import jsonp from 'jsonp-retry'; const url = '//api.example.com/data'; const opts = { timeout: 3000, retryTimes: 1, useStore: true, storeCheckKey: 'version', dataCheck: (data) => data && data.status === 'ok' }; jsonp(url, opts, (err, data) => { if (err) { console.error('JSONP error:', err); return; } console.log('Data:', data); });
Debug
Known issues
gotchaThe `useStore` option defaults to false; if you enable it without setting `storeCheckKey`, it may not work as expected.
fix
Provide both `useStore: true` and `storeCheckKey` (a field name in your data that can serve as a cache validity check).
affects: >=0.0.0
gotchaThe `cache` option does NOT cache the response in memory or localStorage; it controls whether the browser caches the JSONP script request (adding a timestamp to prevent caching). Setting `cache: true` may cause stale data.
fix
If you want to cache data across page loads, use `useStore` instead of `cache`.
affects: >=0.0.0
gotchaJSONP is inherently insecure due to script injection risks; ensure you trust the source URL.
fix
Only use JSONP with trusted endpoints. Consider CORS or other methods instead.
affects: >=0.0.0
gotchaThe library does not handle cross-origin errors beyond timeout; network failures may not be caught properly.
fix
Implement additional error handling using the callback error argument.
affects: >=0.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: jsonp is not defined
Using CommonJS require but with wrong variable name or not installing the package.
fix
Install: npm install jsonp-retry. Import: const jsonp = require('jsonp-retry');
TypeError: jsonp is not a function
Trying to use named import { jsonp } instead of default import.
fix
Use: import jsonp from 'jsonp-retry'; or const jsonp = require('jsonp-retry');
Timeout error: Request timed out
The JSONP request did not complete within `timeout` ms, and retries may be attempted.
fix
Increase the timeout value or ensure the server responds in time.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
jsonp-retry — npm install jsonp-retry · libregistry