Skip to content

Commit

Permalink
add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
keenwon committed Sep 7, 2016
1 parent 653bb2e commit 1479555
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# koa-response-jsonp

koa jsonp middleware

## Install

```shell
npm install koa-response-jsonp --save
```

## Usage

```javascript
const koa = require('koa');
const app = koa();
const jsonp = require('koa-response-jsonp');

jsonp(app);

app.use(function *() {
this.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'
});
```

0 comments on commit 1479555

Please sign in to comment.