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

Thomas Santoro
Thomas Santoro
4,007 Points

"querystring" method not defined - how can a node.js method not be defined?

Snapshot: https://w.trhou.se/w1aw85304u

When I try to run the querystring.parse() method I get the following error--why would a node.js method get a "notdefined" error?

var query = querystring.parse(postBody.toString());
^
ReferenceError: querystring is not defined

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

It looks like you forgot to require/define querystring. You're getting the error that querystring is undefined because you haven't created the variable before you try to use it.