Solution: List all records as JSON


show more Solution: List all records as JSON provides you with in-depth training on Developer. Taught by Joseph LeBlanc as part of the Node.js Essential Training (2013) show less
please wait ...

Solution: List all records as JSON

So, here's my solution to the challenge. I've already installed all the dependencies and I've started the application on port 3000. So, I'm going to go to port 3000 in my browser and then the /list/json route. Now, all the flight information is being displayed as JSON. So let's take a look at how I did this. I'm going to drag the final folder into sublime text two and then I'm going to go to routes slash index dot js. At the very bottom of this file, I created a new function called list json.

Then on line 42, I started a new blank array called flight data On line 44, I started a loop and iterated over all the flights. Then one by one I got the information from each flight object and pushed it into the array. Then, finally on line 48, I sent a res.json response back with the flight data. Then in app.js I attached the list json function to the route /list /json. Now one approach you may have taken while solving this challenge.

Was to just get all the data, from the data module ...

Solution: List all records as JSON
Video duration: 2m 20s 3h 17m Intermediate

Viewers:

Solution: List all records as JSON provides you with in-depth training on Developer. Taught by Joseph LeBlanc as part of the Node.js Essential Training (2013)

Subject:
Developer
Software:
JavaScript Node.js
Author:
please wait ...