egg接收请求参数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bocongbo/article/details/83087775

1、get请求

let query = this.ctx.query;
let name = query.name;
let id = query.id;

2、post请求

let query = this.ctx.request.body;
let name = query.name;
let id = query.id;

3、接口返回值

this.ctx.body = {
    code: 0,
    data: '返回的数据',
    msg: '错误数据'
}

猜你喜欢

转载自blog.csdn.net/bocongbo/article/details/83087775