fetch-jsonp | Make JSONP request like window.fetch | REST library
kandi X-RAY | fetch-jsonp Summary
kandi X-RAY | fetch-jsonp Summary
JSONP is NOT supported in standard Fetch API, 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.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Fetch and fetch a jsonp file
- Clear a function on the window object .
- Remove a script from the document
- Generate a random callback function
fetch-jsonp Key Features
fetch-jsonp Examples and Code Snippets
Community Discussions
Trending Discussions on fetch-jsonp
QUESTION
ANSWER
Answered 2022-Jan-16 at 15:36Resorting to JSONP is frowned upon nowadays; there are safer alternatives, such as CORS, for cross-origin communication. As the response's content type is application/json
, using JSONP will not work anyway because it causes Chrome's CORB feature to kick in.
Why not try to solve whatever CORS issue you seem to be having? I'd be very surprised if the API you're using weren't configured for CORS... A casual inspection of their documentation reveals that you're using the wrong domain, www.gnews.io
, instead of gnews.io
. The former redirects to the latter, but is not configured for CORS, which explains your CORS troubles.
Once you use the right domain (gnews.io
), all your CORS troubles go away. And because there's no longer any need to reach for dirty tricks like JSONP, you can use good old reliable fetch
rather than some third-party tool.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fetch-jsonp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page