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


8,764 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
228,978 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.