-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot destructure property 'name' of 'req.body' as it is undefined. #87
Comments
yeah, I'm also having the same problem... I guess I will figure it out soon, and comment the solution later. |
You need to use express's body parser before adding routes to express. Like this:
|
you can individually take those value like |
you can preview your code again |
app.use(express.json()); |
You passed the username in body data from client side.
…On Wed, Jun 1, 2022, 15:05 omkarpatne38 ***@***.***> wrote:
app.use(express.json());
may be this is missing in your server file
—
Reply to this email directly, view it on GitHub
<#87 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APZCPMZIOIFKC6Y73GUDMG3VM4VFRANCNFSM4WD2JTPQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
You need to use express's body parser before adding routes to express. Like this: |
yes i have same prob |
const app = express(); why not working for me ? // IMPORTS FROM PACKAGES // IMPORTS FROM OTHER FILES // INIT const DB = // middleware // Connections app.listen(PORT, "ip", () => { |
This issue is because body data is not converted into JSON data. So use the below code in the same sequence. app.use(express.json()); It works for me. |
add this to ur main js. then dont use postman when you do the testing. use Thunder Client on VScode extention. |
const app = express(); app.use(express.json()); // to accept JSON data Check if you had added res at firs place instead of req: |
const app = express(); add the above two lines it worked for me |
It work |
thanks bro i was searching friom an hour and got the answer !!! ;) silly mistake |
const bodyParser = require('body-parser'); use body-parser package and added those line top of the app file.. |
In spite of writing this piece of code same error are showing. what to do? |
anyone help me?
The text was updated successfully, but these errors were encountered: