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 trial

JavaScript Build a Simple Dynamic Site with Node.js HTTP Methods and Headers Dealing with the POST Body

Why do you check if the request method is "GET" in the 'home' route?

I've been building an alternative version where a user enters a zipcode into a form and it'll retrieve the weather forecast. I'm confused about why in the home route you'd check if the request method is 'GET' to show the initial search page – it loads fine when I just have if(request.url === "/") {...}, but the request doesn't load anything if I add an if(request.method.toLowerCase === 'get'){...} inside that 'if' clause.

Did you try:

if (request.method.toLowerCase() === 'get'){...}

with parentheses?