/*
if you are using multipart/form-data or
require a file upload from frontend you will need a multer as middleware
for your post/patch requests,
otherwise you can set your frontend to send application/json
*/
<form action="/" method="POST"enctype="application/json">
Make sure your middleware is ordered properly, and if you're using Postman
setting the "Content-Type" header to "application/json" might help.
If testing the API using POSTMAN, ensure that 'Content-Length' header is active and set to <calculated when request is sent>.
// Envirnoment variable
require('dotenv').config()
const express = require('express')
const port = process.env.PORT
const app = express()
const cookieParser = require('cookie-parser')
app.use(express.json())
app.use(cookieParser())
router.post('/profile', (req, res) => {
console.log(req.body);
});
app.listen(port, () => console.log(`Server listening on ${port}`))