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.


8,763 Points

Is there a downfall to chaining?

Was curious after watching the video he wrote it as:

app.post('/goodbye', (req, res) => {

but I was curious if there be any issue to chaining? Think about a very large application I'm trying to stick with cleaning the code as best as possible to reduce size. So I was curious if the above is written like this:

app.post('/goodbye', (req, res) => res.clearCookie('username').redirect('/hello'))

is there a downfall to doing this?

Question is from Solution: Clearing Cookies and Redirecting

1 Answer

Steven Parker
Steven Parker
216,136 Points

There's no negative to chaining as long as each method returns the right object for the next call.

The lesson might not have used it to more clearly illustrate the steps that are being performed.