# tf-jsonp

> jsonp模块

Latest version **0.1.2** (published 2019-05-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install tf-jsonp
pnpm add tf-jsonp
yarn add tf-jsonp
bun add tf-jsonp
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2019-05-05 |
| First published | 2018-11-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 38 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | tffed |

## Links

- npm: https://www.npmjs.com/package/tf-jsonp
- Repository: http://gitlab.tf56.lo/tf-components/tf-jsonp
- npm.io page: https://npm.io/package/tf-jsonp

## Dependencies (1)

- [qs](https://npm.io/package/qs.md) ^6.5.2

## Recent versions

- 0.1.2 (latest) — 2019-05-05
- 0.1.1 — 2019-02-25
- 0.1.0 — 2018-11-28

## README

## jsonp模块

```javascript
// 引入
import JSONP from "tf-jsonp";

JSONP('url地址', {
  callback: 'callback', // 默认callback
  timeout: 10000 // 默认10秒

  // ... // 其它需要传给后端的参数

}, { // 可选, qs的配置, 文档地址: https://www.npmjs.com/package/qs, 下面摘抄了一段
  /*
    When arrays are stringified, by default they are given explicit indices:
    qs.stringify({ a: ['b', 'c', 'd'] });
    // 'a[0]=b&a[1]=c&a[2]=d'

    You may override this by setting the indices option to false:
    qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false });
    // 'a=b&a=c&a=d'

    You may use the arrayFormat option to specify the format of the output array:
    qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
    // 'a[0]=b&a[1]=c'
    qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
    // 'a[]=b&a[]=c'
    qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
    // 'a=b&a=c'
    
    When objects are stringified, by default they use bracket notation:
    qs.stringify({ a: { b: { c: 'd', e: 'f' } } });
    // 'a[b][c]=d&a[b][e]=f'
    
    You may override this to use dot notation by setting the allowDots option to true:
    qs.stringify({ a: { b: { c: 'd', e: 'f' } } }, { allowDots: true });
    // 'a.b.c=d&a.b.e=f'
    
    Empty strings and null values will omit the value, but the equals sign (=) remains in place:
    assert.equal(qs.stringify({ a: '' }), 'a=');
  */
})
.then(data => {
  console.log(data) // 返回的数据
})
.catch(e) {
  console.log(e) // 错误信息
}
```

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