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 REST APIs with Express Create, Read, Update, Delete Create, Read, Update, Delete Quiz 2

Can someone please help me?

Hello, I have tried several times, I cant figure it out.Can you help?

First use the correct Express method to set an HTTP status. Then send a code indicating that the client has sent a bad request:

res.(__).json(data);

1 Answer

Hey Shawnell, first off I would say you should get well acquainted with the Express documentation. It's very helpful and very approachable and you shouldn't be afraid to consult it because looking up the answer isn't cheating! It's what developers do constantly every single day in their work. Second, to set an HTTP status on the response object you use the status() method, and pass it 400, which is the status code for Bad Request. So your code should look like this:

res.status(400).json(data)

Happy coding!