1. const koa = require("koa");
    2. const app = new koa();
    3. const router = require("koa-router")();
    4. router.get("/jsonp",async ctx=>{
    5. let callbackName = ctx.query.callback || 'callback'
    6. // 返回jsonp
    7. var obj ={
    8. name:"cheng",
    9. age:18
    10. }
    11. ctx.body = callbackName + `(${JSON.stringify(obj)})`
    12. })
    13. app.use(router.routes()).use(router.allowedMethods());
    14. app.listen(7000)