Koa cannot get ctx.request.body, through bodyparser. Must it be converted through json?

Front-end axios

this.$axios({
                method:"post",
                url:"/api/login",
                data : {         //json
                  name : this.name,
                  password: this.password
                }

koa

const Koa = require("koa");
const app = new Koa();
const bodyParser = require("koa-bodyparser");
const router = require("./router/main")

app.use(bodyParser()) //POST 

app.use(router.routes());

app.use(router.allowedMethods())  //

app.listen(3000);
user.post("/login",async(ctx)=>{
  console.log("req.body = "+JSON.stringify(ctx.request.body))
  // {"name":"hqb","password":"123"}

  console.log("req.body = "+ctx.request.body)
   //[object Object]

  ctx.body = "LOGIN OK"

clipboard.png

clipboard.png

Mar.09,2021

use ctx.request.body.name, ctx.request.body.password.

ctx.request.body is {name: "hqb", password: "123"}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ace4-2c237.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ace4-2c237.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?