This is the backend for the Pokedex exercises.
npm run db:createnpm run db:migratenpm run db:seed:allnpm run devYour application will need to login a player or sign the player up. Here are the two methods for doing that.
There are three existing players in the database after seeding, all with the password “password”:
| Name | |
|---|---|
| demo@example.com | Demo-lition | 
| yusuke@example.com | Yusuke | 
| petra@example.com | Peta | 
Expected payload sent to server:
Successful response:
{
  "token": "the token to use in your follow-up requests",
  "player": {
    "createdAt": "2019-05-01T08:33:40.799Z",
    "email": "yusuke@example.com",
    "id": 2,
    "name": "Yusuke",
    "updatedAt": "2019-05-01T08:33:40.799Z",
  }
}Expected payload sent to server:
Successful response:
{
  "token": "the token to use in your follow-up requests",
  "player": {
    "createdAt": "2019-05-01T08:33:40.799Z",
    "email": "marco@example.com",
    "id": 4,
    "name": "Marco",
    "updatedAt": "2019-05-01T08:33:40.799Z",
  }
}You need to include the token received from logging in or signing up in this call as a Bearer token for the Authorization header. Set that on the header of the fetch call for this endpoint.
Successful response:
Some of the API results have image URLs associated with them. You can get them from this service. For example, if the service is hosted at http://localhost:8000, then http://localhost:8000/images/pokemon_snaps/5.svg will show the image for the Pokemon with the image URL /images/pokemon_snaps/5.svg.
This is all about listing and creating Pokemon.
You need to include the token received from logging in or signing up in this call as a Bearer token for the Authorization header. Set that on the header of the fetch call for this endpoint.
Successful response:
[
  "fire",
  "electric",
  "normal",
  "ghost",
  "psychic",
  "water",
  "bug",
  "dragon",
  "grass",
  "fighting",
  "ice",
  "flying",
  "poison",
  "ground",
  "rock",
  "steel"
]You need to include the token received from logging in or signing up in this call as a Bearer token for the Authorization header. Set that on the header of the fetch call for this endpoint.
Successful response looks like this with more entries:
[
  {
    "imageUrl": "/images/pokemon_snaps/1.svg",
    "name": "Bulbasaur",
    "updatedAt": "2019-05-01T08:33:40.799Z"
  }
]You need to include the token received from logging in or signing up in this call as a Bearer token for the Authorization header. Set that on the header of the fetch call for this endpoint.
Successful response looks like this for the given id:
{
  "attack": 90,
  "defense": 55,
  "imageUrl": "/images/pokemon_snaps/26.svg",
  "name": "Raichu5",
  "type": "electric",
  "moves": [
    "thundershock",
    "thunderbolt"
  ],
  "items": [],
  "owner": {
    "id": 2,
    "name": "Yusuke"
  }
}You need to include the token received from logging in or signing up in this call as a Bearer token for the Authorization header. Set that on the header of the fetch call for this endpoint.
The payload that you must send looks like this.
{
  "attack": 90,
  "defense": 55,
  "imageUrl": "/images/pokemon_snaps/26.svg",
  "name": "Billy goat gruff",
  "type": "food",
  "moves": [
    "eating trash",
    "eating anything"
  ]
}Successful response looks like this:
{
  "attack": 90,
  "defense": 55,
  "imageUrl": "/images/pokemon_snaps/26.svg",
  "name": "Billy goat gruff",
  "type": "food",
  "moves": [
    "eating trash",
    "eating anything"
  ],
  "items": [
    {
      "name": "Ergonomic Cotton Keyboard",
      "price": 37,
      "happiness": 36,
      "imageUrl": "/images/pokemon_berry.svg"
    },
    {
      "name": "Tasty Concrete Pants",
      "price": 79,
      "happiness": 74,
      "imageUrl": "/images/pokemon_egg.svg"
    },
    {
      "name": "Fantastic Metal Bacon",
      "price": 80,
      "happiness": 61,
      "imageUrl": "/images/pokemon_super_potion.svg"
    }
  ],
  "owner": {
    "id": 2,
    "name": "Yusuke"
  }
}