Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Using the provided template, create a POST endpoint that returns data from the Pokémon API in the following format: The endpoint will take a body with the array named “ids” that includes the Pokémon...

1 answer below »

Using the provided template, create a POST endpoint that returns data from the Pokémon API in the
following format:
The endpoint will take a body with the a
ay named “ids” that includes the Pokémon IDs you want the
endpoint to return data for. The endpoint should use a Promise.all to request the individual Pokemon
data from the PokeAPI.
The endpoint will call variants of the URL: https:
pokeapi.co/api/v2/pokemon/${pokemonID}/ and
extract the required data from the return value.
For “sprite”, I’m looking specifically for “front_default” in the sprites object.
https:
pokeapi.co/api/v2/pokemon/$%7bpokemonID%7d
Additionally, if an invalid ID is given your endpoint should return the following object for that ID:
You will use most of the same techniques as what was presented in week 11. However, this will be a
POST request rather than a GET that takes in a body. You will have to do some research into how to use
a request body in Express. HINT: It is a part of the request object, req.
Important: Normally, I would allow you to use any NPM modules you want but for making network
equests YOU MUST USE SUPERAGENT. There is a jest testing suite that I will be using to grade your
project just like the first homework assignment which depends on superagent. Run npm run test to see
the results of the tests as you write your code. You may have to ctrl + c to exit the tests. The supertest
framework I use is finicky.
The tests found in pokemon.test.js will let you know what I’m looking for and give you an idea of where
to find the data I want in the Pokemon API object.
Grading Criteria:
All tests pass: 10 points
Uses Promise.all: 5 points
Node_modules folder removed: 5 points
Zip file is not named in the format, WeinbergAssignment3.zip: -5 points
EXTRA CREDIT: Write a UI that hits your post endpoint. The UI should display the data returned from this
endpoint, including the sprite (as an image!). The sprite is a png. Have fun with this one, maybe make it
look like a Pokemon Card. If you want to include more data in your endpoint (which would cause the
tests to fail) just let me know when you turn it in. As long as you have the notfound object for a bad id
and the return objects have name, sprite, and type you will get full credit regardless of the tests. This
extra credit will be worth an additional 20 points.
Grading Criteria:
No console or “white page” e
ors – 5 points
Uses a component li
ary – 5 points
Node_modules folder removed – 5 points
Some way for the user to enter the IDs (URL parameter, text box, etc) – 5 points
Answered Same Day Apr 20, 2022

Solution

Raja answered on Apr 21 2022
100 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here