Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Express Basics Deeper into Routing with Express POST Requests

Seth M
seal-mask
.a{fill-rule:evenodd;}techdegree
Seth M
Web Development Techdegree Student 12,271 Points

Is express().get still required?

I've been following along with the video, but I did not receive an error when running the form with only a get request. This is my code in app.js for the 'hello' route:

app.get('/hello', (req, res) => {
    res.render('hello');
});

Andrew suggest adding app.post with all the same information to avoid an error. Is this a difference between HTTP and HTTP2?

Thanks!

1 Answer

Seth M
seal-mask
.a{fill-rule:evenodd;}techdegree
Seth M
Web Development Techdegree Student 12,271 Points

I found the reason I wasn't receiving an error. When I made my form (in the hello.pug file) I used the following code:

form(action='/hello', methods='post')

methods should have been method. hope this helps if someone made the same mistake I did.