Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

why is my req.body empty

Make sure your middleware is ordered properly, and if you're using Postman 
setting the "Content-Type" header to "application/json" might help.
Comment

getting empty req.body

If testing the API using POSTMAN, ensure that 'Content-Length' header is active and set to <calculated when request is sent>.
Comment

req.body empty on posts

// 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}`))
Comment

PREVIOUS NEXT
Code Example
Javascript :: check if key does not exists in dictionary javascript 
Javascript :: jspdf pdf from html 
Javascript :: how to add important tag js 
Javascript :: settimeout in javascript 
Javascript :: javascript Inserting values in between an array 
Javascript :: get random item from array javascript 
Javascript :: jquery button top to bottom 
Javascript :: react hook form with yup resolver 
Javascript :: what is the correct json content type 
Javascript :: detect logged user wordpress javascript 
Javascript :: nodejs how to send html 
Javascript :: Loop over all keys in the local storage 
Javascript :: how to make apk of react native app 
Javascript :: moment time format by country 
Javascript :: array map limit javascript 
Javascript :: es ignore 
Javascript :: javascript get element by rel attribute 
Javascript :: copy one array to another javascript 
Javascript :: how to send query parameters in url vuejs 
Javascript :: check if two rectangles overlap javascript canvas 
Javascript :: set background color dynamically javascript 
Javascript :: unity javascript 
Javascript :: convert to 24 hours format javasript 
Javascript :: jquery addeventlistener wheel 
Javascript :: event.preventdefault is not a function jquery 
Javascript :: how to change materil ui divider coloer 
Javascript :: react app js 
Javascript :: es6 array sum javascript 
Javascript :: javascript get current date format dd mm yyyy hh mm ss 
Javascript :: how to separate thousands with comma in js 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =