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 trialJon Holewa
349 PointsI added 'res.send({todos:[]});' but it is not converted to json in the browser? (unlike video)
When I went through the step of adding "res.send({todos:[]}" to the api GET method, it does not convert to a JSON object like it does in the video. I also tried changing the command from 'res.send' to 'res.json' but it still returns exactly as written in the function, instead of the formatting changing to that of JSON like it does in the video.
ex. it shows {todos:[]} in the browser, instead of...
{ todos: [] }
4 Answers
Seth Kroger
56,413 PointsThe only difference between the two is formatting. Unformatted, it's usually compressed into a single line without spacing. Huston is almost certainly using a browser extension to display JSON in a more readable way. (JSONView is one; available on Firefox and Chrome).
David Tonge
Courses Plus Student 45,640 PointsThat's the correct behavior if you're watching this video that's attached to your question. Calling for dummy data happens in the other video.
Jon Holewa
349 PointsI think I'm a little confused - are you saying it should be expanding to display in JSON format? So far I've only watched the video attached to my question which is where I noticed that behavior (which wasn't occurring on my machine). The other answer suggested that it may be a browser extension on the instructors machine which is making it display in JSON format.
Nathan Minarik
590 PointsYeah you should get this extension (very useful for any project which you're working with JSON data on) https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc
Pedro Sousa
14,074 PointsJSONview has since been deprecated for Chrome. I would suggest using the extension JSON Formatter instead.
Jon Holewa
349 PointsJon Holewa
349 PointsGood to know! I won't worry about it too much then - thank you!