post请求

  1. /app/config/config.default.js
  2. config.security = {
  3. csrf: {
  4. enable: false
  5. }
  6. }
  7. //关闭csrf就可以获取post请求的数据

获取post 请求数据

  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. class LoginController extends Controller {
  4. async index() {
  5. const { ctx } = this;
  6. ctx.body = 'hi, login';
  7. console.log(ctx.request.body);
  8. }
  9. }
  10. module.exports = LoginController;