# Restful接口示例

  • 常见的GET/POST

get

router.get("/get", (ctx) => {
  const params = ctx.request.query
  // name: 'xcooo'  age: 18
  console.log(params.name, params.age)

  ctx.body = {
    name: params.name,
    age: params.age
  };
});
1
2
3
4
5
6
7
8
9
10

post

router.post("/post", async (ctx) => {
  let { body } = ctx.request;
  ctx.body = {
    ...body,
  };
});
1
2
3
4
5
6
  • 统一的数据处理
  • 接口调式及日志
上次更新: 2020/12/4 下午3:37:40