When express router.post, res.body is undefined

when res.body is undefined through the query, it is because body-parser is not loaded, but I do not have such a problem, but I also return undefined. What the heck is it?

//server.js  body-parser 
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const app = express();

app.use(bodyParser.urlencoded({extended:false}))  
app.use(bodyParser.json());
app.use(passport.initialize());

const anvizApi = require("./router/api/anviz/home");

app.use("/api/anviz/home",anvizApi);
//router/api/anviz/home.js
//res.body  undefined
router.post("/banner",passportInfo,(req,res) => {

    const {msg,isValid} = homeBannerValidator(req.body);
    if(!isValid){
        return res.status(400).json(msg);
    }

    HomeSchema.findOne({banner:req.body._id}).then(banner => {
      console.log("current:   " + res.body);

        //Model 
        const newBanner = {
            handle:req.body.handle,
            bannerBg:req.body.bannerBg,
            bannerName:req.body.bannerName,
            bannerSubName:req.body.bannerSubName,
            bannerFeather:req.body.bannerFeather,
            bannerLink:req.body.bannerLink
      };
      banner.prodcutBanner = newBanner;
      banner.then(banner => res.json(banner));
    })
    .catch((err) => res.json(err));
});

module.exports = router;
//Schema
const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const HomeSchema = new Schema({
    handle:{
        type:Boolean
    },
    prodcutBanner:{
        bannerBg:{
            type:String,
            required:true
        },
        bannerName:{
            type:String,
            required:true
        },
        bannerSubName:{
            type:String
        },
        bannerFeather:{
            type:String
        },
        bannerLink:{
            type:String
        }
    },
    prodcutList:[
        {
            prodctName:{
                type: String,
                required:true
            },
            prodctSubTitel:{
                type:String,
                required:true
            },
            prodctDes:{
                type:String,
                required:true
            },
            prodctLink:{
                type:String,
                required:true
            },
            prodctImg:{
                type:String,
                required:true
            },
            prodctFeature:[
                {
                    name:{
                        type:String
                    }
                }
            ]
        }
    ],
    prodctCase:[
        {
            caseImg:{
                type:String,
                required:true
            },
            caseTitle:{
                type:String,
                required:true
            },
            caseSubTitle:{
                type:String,
                required:true
            },
            caseLink:{
                type:String,
                required:true
            }
        }
    ]
});

module.exports = mongoose.model("home",HomeSchema);

when I pass the postman test, the value in form is available:

clipboard.png

postman

ask for advice! Thank you!

Apr.07,2022

did you add your bodyParser to use?

banner.prodcutBanner = newBanner;
      banner.then(banner => {
          console.log(banner);
          res.json(banner);
      });
      

print

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-1bc9054-38d03.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-1bc9054-38d03.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?