CS546 Lab 5-JSON Routes Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

JSON Routes

For this lab, you will create a simple server that will provide data from an API. For this lab, you will not need to use a database.

For this lab, you must use the async/await keywords (not Promises). You will also be using (https://github.com/axios/axios) , which is a HTTP client for Node.js; you can install it with
just as you did in lab 3.

Network JSON Data

You will be downloading JSON files from the following GitHub Gists:

. You will use it

axios

npm i axios

people.json (https://gist.githubusercontent.com/graffixnyc/a1196cbf008e85a8e808dc60d4db7261/raw/9fd0d1a4d7846 stocks.json (Links to an external site.) (https://gist.githubusercontent.com/graffixnyc/8c363d85e61863ac044097c0d199dbcc/raw/7d79752a9342a

Your routes

/people

/stocks

http://localhost:3000/people
http://localhost:3000/stocks

people.json

stocks.json

When making a GET request to

from the axios call to the URL endpoint. You will use JSON format.

When making a GET request to
from the axios call to the URL endpoint. You will use JSON format.

b c

, this route will return the JSON data that is returned for the list of people. You MUST return the data in

, this route will return the JSON data that is returned for the list of stocks. You MUST return the data in

https://sit.instructure.com/courses/50148/assignments/273385

1/2

12/14/21, 11:46 PM Lab 5

/people/:id

When making a GET request to http://localhost:3000/people/:id , this route will return the JSON data. You will use people.json Where :id is the parameter that is passed to the route: http://localhost:3000/people/4c570a2a- 5f3d-4309-b81c-2f6b36965ecc This endpoint returns a JSON object that has all the details for the person with that with the supplied :id If the ID cannot be found in the Data(i.e. there is no person with that ID), or if the URL parameter is any other data type besides a valid string, you will throw an error. You MUST return the data in JSON format.

/stocks/:id

When making a GET request to , this route will return the JSON data that is returned from the axios call to the URL endpoint. You will use Where :id is the parameter that is passed to the route: http://localhost:3000/stocks/929686a2-dd3a-42c7-a88d-b170e2590252 This endpoint returns a JSON object that has all the details for the stock with that with the supplied :id If the ID cannot be found in the Data(i.e. there is no stock with that ID), or if the URL parameter is any other data type besides a valid string, you will throw an error. You MUST return the data in JSON format.

Packages you will use:

http://localhost:3000/stocks/:id

stocks.json

You will use the express package as your server.
You will use the axios package to get data from the API.

You can read up on express (http://expressjs.com/) on its home page. Specifically, you may find the API Guide section on requests (http://expressjs.com/en/4x/api.html#req) useful.

You may use the lecture 5 code (https://github.com/stevens-cs546-cs554/CS-546/tree/master/lecture_05/code) as a guide.

You must save all dependencies to your package.json file

  • lab5-wecg9q.zip