Getting Data in Request Body in Instagram Clone
Step 01: Create the folder named routes and create file auth.js in that
Step 02: We need to require express and use it in router
Step 03: Create a route and also export that route
Step 04: Now We can Register this route in App.js:
Step 05: Make the Signup Route basically with console.log and test it at the Postman
In Postman-
Headers : content-Type:Application/json
Body: {
name:"mukesh"
}
but it will not work in response because in postamn
our express server does not pass the request to the json , we need to tell it to the server
this is a type of middleware and i will write it in the app.use - because we want to take all the incoming request that to the json
and change it to the req.body
and the postman will be hang after hitting the request
I will use express.json before the route not after the route and we have to take care about it-Order obviously Matter.
Comments
Post a Comment