Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keenwon/koa-response-jsonp
koa jsonp middleware
https://github.com/keenwon/koa-response-jsonp
jsonp koa koa-middleware koajs
Last synced: 3 months ago
JSON representation
koa jsonp middleware
- Host: GitHub
- URL: https://github.com/keenwon/koa-response-jsonp
- Owner: keenwon
- License: mit
- Created: 2016-09-07T07:58:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:38:29.000Z (about 2 years ago)
- Last Synced: 2024-10-01T02:21:37.457Z (3 months ago)
- Topics: jsonp, koa, koa-middleware, koajs
- Language: JavaScript
- Size: 768 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-koa - koa-response-jsonp - KOA JSONP中间件。 ![](https://img.shields.io/github/stars/keenwon/koa-response-jsonp.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/koa-response-jsonp.svg?style=flat-square) (仓库 / 中间件)
README
# koa-response-jsonp
[![NPM version][npm-image]][npm-url]
[![Node version][node-image]][node-url]
[![Build Status][github-actions-image]][github-actions-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![npm download][download-image]][download-url]koa jsonp middleware
## Install
```shell
npm install koa-response-jsonp --save
```## Usage
```javascript
const Koa = require('koa');
const app = new Koa();
const jsonp = require('koa-response-jsonp');jsonp(app);
app.use(async ctx => {
ctx.jsonp({
success: true
});
});app.listen(3000);
```then you request `http://localhost:3000?callback=fn` will response:
```javascript
fn({"success":true})
```custom callback functoin name:
```javascript
jsonp(app, {
callbackFn: 'cb'
});
```[npm-image]: https://img.shields.io/npm/v/koa-response-jsonp.svg
[npm-url]: https://www.npmjs.com/package/koa-response-jsonp
[node-image]: https://img.shields.io/node/v/koa-response-jsonp.svg
[node-url]: https://nodejs.org
[github-actions-image]: https://github.com/keenwon/koa-response-jsonp/workflows/unittest/badge.svg
[github-actions-url]: https://github.com/keenwon/koa-response-jsonp/actions
[coveralls-image]: https://img.shields.io/codecov/c/github/keenwon/koa-response-jsonp
[coveralls-url]: https://codecov.io/gh/keenwon/koa-response-jsonp
[download-image]: https://img.shields.io/npm/dm/koa-response-jsonp.svg
[download-url]: https://npmjs.org/package/koa-response-jsonp