0

data not arriving in req.body when using axios in post methord, when i testing Api using postman is Working properly,

in console payload also showing,

Pay load :- enter image description here

Api Call:

axios.post('offices/office',{name,email},config)
      .then((res) => {
        console.log(res)
      })
      .catch((err) => {
        console.log(err)
      });

axios instance:

import axios from 'axios'
import { BaseUrl } from './Api';
const instance = axios.create({
    baseURL:BaseUrl,
  });

export default instance 

Server :

enter image description here

code : officeRouter:

const express =require('express')
const { createOffice } = require('../Controller/Office_Controller')
const router=express.Router()
router.post('/office',createOffice)
module.exports=router

controller.js

createOffice:async(req,res) => {
    console.log(req.body)
   },
Pradeep Kumar
  • 1,193
  • 1
  • 9
  • 21
  • Does this answer your question? [req.body empty on posts](https://stackoverflow.com/questions/24543847/req-body-empty-on-posts) – Slava Knyazev Nov 14 '22 at 19:06

0 Answers0