App.js
app.use(express.json({limit:"30mb",extended:true}));
app.use(express.urlencoded({extended:true}));
route.js
router.route("/register").post(registerUser)
importing Routes in app.js
import userRoute from './routes/user.route.js';
app.use("/users",userRoute);```
const {fullName,email,username,password} = req.body;
console.log("req.body: ",req.body);
output:
req.body: {}
Error: All input is required
I'm trying to register user with files but req.body is empty if I'm trying to use normal form in postman but if I'm trying x-www-form-urlencoded it works but cann't upload file there
>Solution :
In route.js File
router.post("/register", (req, res) => {
const {fullName, email, username, password} = req.body;
console.log("req.body: ",req.body);
});
Using this code.
I think it resolve your problem.
If nothing happened, please check sending message in Network of the Browser.