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 trialShawn Lindsey
20,952 PointsWhat's the purpose of sending a response when sending a post request?
I understand every bit of the request code here, but I'm not completely understanding the res.json() part. Is this just for verification on the client end that the request was properly received and stored?
2 Answers
James Crosslin
Full Stack JavaScript Techdegree Graduate 16,882 PointsYes, it is for verification for the client that the request was properly received and stored. This response would then be used by an app to say "Comment Posted" or "Profile Image Created", etc, and then display it on the page as it appears on the server side.
Simon Coates
8,225 PointsI'd never really questioned it. On some operations, the returned value might differ from the posted one. For instance, the updated record could have an id or generated or transformed fields maybe.