I have a scipt tag in which im making a post request to a route through axios.Axios is not sending the parameters through. Here is the code for axios:
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> <script type="text/javascript"> const data={'firstName':"sai"} axios({ url: "/", method: "post", data: data, }) .then(response => { console.log(response); }) .catch(error => console.error(error)); </script> Here is the express side of things:
app.post("/",function(req,res){ console.log("post route"); console.log(req.body); }) Im console.logging the data coming from the post request with the help of req.body(I also have body-parser working just fine.Tested with other normal forms).The req comes through to hit the post route.BUt the body is empty always logs "{}". Please help me out with this.