Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKatie Shook
12,326 Pointsnot getting any information from the console. It's just printing {} in the terminal.
Hey everyone. I'm not getting any of that bulk info in the body that Andrew did. When I submit the form {} was printing in my terminal but now nothing is. Also not sure if this is related but my form keeps disappearing and I have to click on it. Here are some snippets of my code.
hello.pug : extends layout
block content h2 Welcome, Student! form(action='/hello' , method='post') label Please enter your name input(type= 'text' , name='name') button(type='submit') Submit
app.js : const bodyParser = require('body-parser'); app.use(bodyParser.urlencoded( { extended : false } )); app.set('view engine', 'pug'); app.get('/hello', (req, res) => { console.dir(req.body); res.render('hello'); }) app.post('/hello', (req, res) => { res.render('hello'); })
Any help is appreciated! Thanks!
2 Answers
Seokhyun Wie
Full Stack JavaScript Techdegree Graduate 21,606 Pointsluther wardle I am having the same issue, but your console.dir(req.body)
is inside of GET request. It has to go inside the POST request. Thanks.
luther wardle
Full Stack JavaScript Techdegree Student 18,029 Pointsluther wardle
Full Stack JavaScript Techdegree Student 18,029 PointsHi Katie, I have formatted your app.js for better readability. I am currently dealing with the same issue. If I run across a solution I will post it :)
In the meantime, if you are sure you have no syntax errors in your code, restarting your development server may resolve the issue, some changes simply might not have taken effect in your current instance of the server.
I have listed the commands for code formatting below for future reference.
Code Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.