Using express and javascript, the request object, and including npm packages and node modules. You have a collection of Pokemon cards that you'd like to
Using express and javascript, the request object, and including npm packages and node modules.
You have a collection of Pokemon cards that you'd like to share with other people as both an HTML website and a JSON data feed. When visitors come to your website, they will see the collection of cards displayed in a list on the home page.
You also want to provide an API data feed in JSON format for more advanced querying. Your cards are available for trade or purchase, so you want to be sure to include all relevant data in your data feed.
Data Format:
JSON objects returned from this app should match this format. I know cards have more stats than this, I'm just keeping it simple. Here's a JSON file Download Here's a JSON file containing some sample pokemon for you to use.
id: number - The Pokemon's assigned ID
name: string
type: string[] - string array since Pokemon can have multiple types
hp: string - Hit points (basically how much damage the Pokemon can take)
willTrade: boolean - Will be true if I'm willing to trade
price: number - Will be null if the card is not for sale
App Requirements:
Your app should have the following HTML routes defined:
The "/" route lists all cards in your collection in HTML format (note that this is the ONLY HTML route in this app)
The "/api/cards" route lists all cards in your collection in JSON
The "/api/cards/trade" route lists only the cards that you are willing to trade in JSON
The "/api/cards/sell" route lists only the cards that are for sale in JSON
Card info should be stored in memory as an array of objects. When a customer visits your site this data should be sent to them in JSON format.
Hint: look into the res.json() method in Express
Bonus: (15 points)
I will award a 15 point bonus if your app allows the user to filter by type using a query parameter on all routes. For example: "/api/cards/trade?type=fire" should show me all cards that are available for trade of fire type only.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started