# pjsonp

> JSONP wrapped in Promise API.

Latest version **1.0.1** (published 2018-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install pjsonp
pnpm add pjsonp
yarn add pjsonp
bun add pjsonp
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-03-31 |
| First published | 2018-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Wendell Hu |
| Maintainers | wendzhue |
| Keywords | jsonp, promise, util |

## Links

- npm: https://www.npmjs.com/package/pjsonp
- Repository: https://github.com/wendzhue/promise-jsonp
- Homepage: https://github.com/wendzhue/promise-jsonp#readme
- Issues: https://github.com/wendzhue/promise-jsonp/issues
- npm.io page: https://npm.io/package/pjsonp

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-03-31
- 1.0.0 — 2018-03-31

## README

# pjsonp

> jsonp with elegent Promise API.

## Installation

```sh
npm install pjsonp --save
```

## API

```js
const pjsonp = require('path/to/pjsonp')
const url = 'http://jsfiddle.net/echo/jsonp/'
const params = {
  beep: 'boop',
  yo: 'dawg'
}
const options = {
  timeout: 1,
  name: 'namedCb'
}

pjsonp(url, params, options)
  .then(data => {
    /* deal with the data you just fetched! */
  })
  .catch(err => {
    /* timeout err by default */
  })
```

* `url`: url to fetch data. It should look like `http://somehostname[:someport]/to/some/path[?with=true&orWithoutQueries=false]`
* `params` (optional): an plain object that contains parameters. Considering jsonp is all about 'GET', promise-jsonp will parse them into `url` for you. But if you don't have parameters or have enclosed them in `url`, that's fine. Just ignore `params`.
* `options` (optional, but you can't just provide `params` without `options`):
  * `prefix`: prefix of jsonp callback function. Default: `__jp`.
  * `timeout`: literal meaning. Default: `60000`, in milliseconds.
  * `name`: the name of callback function. If set, `prefix` would be invalid. Default: `undefined`.
  * `param`: name of the query string parameter to specify the callback. Default: `callback`.

## Test

Test with Jest. Run `npm run test`.

## LICENSE

MIT

---
_Source: https://npm.io/package/pjsonp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
