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

Error: write after end

When sending a POST request with a username, I am receiving the message:

events.js:160 throw er; // Unhandled 'error' event ^

Error: write after end at ServerResponse.OutgoingMessage.write (http_outgoing.js:426:15) at IncomingMessage.<anonymous< (/home/treehouse/workspace/router.js:26:20) at emitOne (events.js:96:13) at IncomingMessage.emit (events.js:188.7) at IncomingMessage.Readable.read (_stream_readable.js:387:10) at flow (_stream_readable.js:772:26) at resume (_stream_readable.js:772:26) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

Not sure what's triggering this error, but for the incoming message at router.js:26:20 my code looks as such: response.write(query.username);

Steven Parker
Steven Parker
229,644 Points

This may be the line where the error occurs, but the problem leading up to it is somewhere else.

Share the complete code, or make a snapshot of your workspace and post the link to it here.