https://github.com/derhuerst/parse-jsonp
Get the payload of a JSONP response.
https://github.com/derhuerst/parse-jsonp
ajax cors fetch jsonp
Last synced: 11 months ago
JSON representation
Get the payload of a JSONP response.
- Host: GitHub
- URL: https://github.com/derhuerst/parse-jsonp
- Owner: derhuerst
- License: isc
- Created: 2017-07-20T17:47:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-12T01:56:14.000Z (almost 6 years ago)
- Last Synced: 2024-12-25T00:30:23.773Z (about 1 year ago)
- Topics: ajax, cors, fetch, jsonp
- Language: JavaScript
- Homepage: https://github.com/derhuerst/parse-jsonp
- Size: 99.6 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# parse-jsonp
**Get the payload of a [JSONP](https://en.wikipedia.org/wiki/JSONP) response** in Node.js and in the browser. No `fetch`/AJAX logic in here.
[](https://www.npmjs.com/package/parse-jsonp)
[](https://travis-ci.org/derhuerst/parse-jsonp)

[](https://gitter.im/derhuerst)
[](https://patreon.com/derhuerst)
## Installing
```shell
npm install parse-jsonp
```
## Usage
```js
const {fetch} = require('fetch-ponyfill')()
const parse = require('parse-jsonp')
fetch('some-JSONP-url.js')
.then((res) => res.text())
.then((jsonp) => parse('callback', jsonp))
.then(console.log, console.error)
```
## API
```js
parse(hook, jsonp)
```
## Contributing
If you have a question or have difficulties using `parse-jsonp`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/parse-jsonp/issues).