A JSONP adapter for Axios that provides a drop-in replacement for XHR-based requests, supporting promises, cancellation, and a familiar API. Version 1.0.4 is the latest stable release; the package is in maintenance mode with infrequent updates. It is the de facto standard for JSONP with Axios, offering minimal configuration via `callbackParamName` and seamless integration with Axios interceptors and error handling. Unlike custom JSONP implementations, it reuses Axios's promise and cancellation patterns, reducing boilerplate.
npm install axios-jsonpNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a JSONP request with Axios using the adapter, including error handling and timeout.
Ensure all JSONP requests use GET method. Use Axios's 'method' field or default GET behavior.
Use only in browser environments. For Node.js, consider a JSONP polyfill or purely server-side data fetching.
Consider migrating to Fetch API with a JSONP wrapper or CORS-enabled endpoints.
Use Axios's CancelToken for cancellation. Example: const source = axios.CancelToken.source(); axios({ cancelToken: source.token, adapter: jsonpAdapter });Check the URL is correct and the server supports JSONP. Use browser DevTools to verify the script tag is appended and the response is valid.
Ensure correct import: `import jsonpAdapter from 'axios-jsonp'`. For CommonJS: `const jsonpAdapter = require('axios-jsonp').default` or check module system.The adapter automatically creates a global callback function named after the callbackParamName. Ensure the callbackParamName matches what the server expects. Default is 'callback'.