Gathering detailed insights and metrics for fetch-jsonp
Gathering detailed insights and metrics for fetch-jsonp
Gathering detailed insights and metrics for fetch-jsonp
Gathering detailed insights and metrics for fetch-jsonp
npm install fetch-jsonp
Typescript
Module System
Node Version
NPM Version
99.8
Supply Chain
100
Quality
76.1
Maintenance
100
Vulnerability
100
License
Allow applications to set crossorigin attribute
Updated on Jul 06, 2023
Set values of options to be optional
Updated on Sep 13, 2022
Add referrerPolicy support
Updated on Aug 17, 2021
Add nonce support
Updated on Aug 16, 2021
fix timeout ReferenceError
Updated on Aug 29, 2017
Fix script error when script request error
Updated on Jun 10, 2017
JavaScript (100%)
Total Downloads
23,479,125
Last Day
2,369
Last Week
73,837
Last Month
324,290
Last Year
3,918,938
1,004 Stars
80 Commits
156 Forks
25 Watchers
3 Branches
15 Contributors
Updated on Jun 25, 2025
Minified
Minified + Gzipped
Latest Version
1.3.0
Package Id
fetch-jsonp@1.3.0
Unpacked Size
12.10 kB
Size
4.41 kB
File Count
8
NPM Version
8.19.4
Node Version
16.20.0
Published on
Jul 06, 2023
Cumulative downloads
Total Downloads
Last Day
-18.3%
2,369
Compared to previous day
Last Week
-5.5%
73,837
Compared to previous week
Last Month
2.3%
324,290
Compared to previous month
Last Year
9.9%
3,918,938
Compared to previous year
JSONP is NOT supported in standard Fetch API, https://fetch.spec.whatwg.org.
fetch-jsonp provides you same API to fetch JSONP like native Fetch, also comes
with global fetchJsonp
function.
If you need a fetch
polyfill for old browsers, try github/fetch.
You can install with npm
.
npm install fetch-jsonp
IE8/9/10/11 does not support ES6 Promise, run this to polyfill the global environment at the beginning of your application.
1require('es6-promise').polyfill();
JSONP only supports GET method, same as fetch-jsonp
.
1fetchJsonp('/users.jsonp') 2 .then(function(response) { 3 return response.json() 4 }).then(function(json) { 5 console.log('parsed json', json) 6 }).catch(function(ex) { 7 console.log('parsing failed', ex) 8 })
1fetchJsonp('/users.jsonp', { 2 jsonpCallback: 'custom_callback', 3 }) 4 .then(function(response) { 5 return response.json() 6 }).then(function(json) { 7 console.log('parsed json', json) 8 }).catch(function(ex) { 9 console.log('parsing failed', ex) 10 })
json_
prefix1fetchJsonp('/users.jsonp', { 2 jsonpCallbackFunction: 'function_name_of_jsonp_response' 3 }) 4 .then(function(response) { 5 return response.json() 6 }).then(function(json) { 7 console.log('parsed json', json) 8 }).catch(function(ex) { 9 console.log('parsing failed', ex) 10 })
1fetchJsonp('/users.jsonp', { 2 timeout: 3000, 3 }) 4 .then(function(response) { 5 return response.json() 6 }).then(function(json) { 7 console.log('parsed json', json) 8 }).catch(function(ex) { 9 console.log('parsing failed', ex) 10 })
jsonpCallback
and jsonpCallbackFunction
There two functions can easily be confused with each other, but there is a clear distinction.
Default values are
jsonpCallback
, default value is callback
. It's the name of the callback parameterjsonpCallbackFunction
, default value is null
. It's the name of the callback function. In order to make it distinct, it's a random string with jsonp_
prefix like jsonp_1497658186785_39551
. Leave it blank if it's set by the server, set it explicitly if the callback function name is fixed.1fetchJsonp('/users.jsonp', {
2 jsonpCallback: 'cb'
3})
The request url will be /users.jsonp?cb=jsonp_1497658186785_39551
, and the server should respond with a function like:
1jsonp_1497658186785_39551( 2 { ...data here... } 3)
1fetchJsonp('/users.jsonp', {
2 jsonpCallbackFunction: 'search_results'
3})
The request url will be /users.jsonp?callback=search_results
, and the server should always respond with a function named search_results
like:
1search_results( 2 { ...data here... } 3)
.then(function(response) { return response.json(); })
in order to keep consistent with Fetch API.Uncaught SyntaxError: Unexpected token :
errorMore than likely, you are calling a JSON api, which does not support JSONP. The difference is that JSON api responds with an object like {"data": 123}
and will throw the error above when being executed as a function. On the other hand, JSONP will respond with a function wrapped object like jsonp_123132({data: 123})
.
![]() | ![]() | ![]() | ![]() | ![]() |
---|---|---|---|---|
Latest ✔ | Latest ✔ | 8+ ✔ | Latest ✔ | 6.1+ ✔ |
MIT
Thanks to github/fetch for bring Fetch to old browsers.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 8/22 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More