![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Koa
873587091
这个作者很懒,什么都没留下…
展开
-
koa获取get请求、querystring以及state使用
1. 获取get请求 相比于post请求 get请求就比较简单一些了 router.get('/getData',async (ctx,next)=>{ console.log(ctx.request.url); // "/?name=xxx&age=111" 字符串 console.log(ctx.request.query...原创 2020-04-27 00:00:15 · 1055 阅读 · 0 评论 -
koa-bodyparser获取post参数
1.不使用koa-bodyparser获取post参数 router.post('/postData',async (ctx,next)=>{ let postData=""; // 用于存储post的数据 ctx.req.on('data',function(data){ postData+=data; ...原创 2020-04-26 23:24:54 · 693 阅读 · 0 评论 -
koa-router基本使用
1. 安装 npm i koa-router 2. 导入 const router=require('koa-router')({ prefix:"/user", // 路由前缀 }); 3. 不同请求 请求方式有get、post、put、del、all,主要使用get和post,all接收所有请求类型 // 修改为其他请求类型,只需要将get改成需要的类型即可 router.get(...原创 2020-04-26 18:09:06 · 1591 阅读 · 0 评论 -
koa-static基本使用
1. 安装koa-static npm i koa-static 2. 导入 const serve = require('koa-static'); // 导入koa-static包 const Koa = require('koa'); // 导入koa包 const app = new Koa(); // 创建koa实例对象 3. 使用 app.use(stat...原创 2020-04-26 17:09:46 · 5731 阅读 · 0 评论