PokeAPI / pokedex-promise-v2

An easy way to use pokeapi v2 with promises in node.js
MIT License
516 stars 91 forks source link

Get [object] in some informations #47

Closed GuikiPT closed 3 years ago

GuikiPT commented 3 years ago

Hello, im testing the PokéAPI with pokedex-promise-v2 and when i sent this to console, im getting some information with [object]

here its a example from the pokemon

{
  abilities: [
    { ability: [Object], is_hidden: false, slot: 1 },
    { ability: [Object], is_hidden: false, slot: 2 },
    { ability: [Object], is_hidden: true, slot: 3 }
  ],
  base_experience: 184,
  forms: [
    {
      name: 'lucario',
      url: 'https://pokeapi.co/api/v2/pokemon-form/448/'
    }
  ],
  game_indices: [
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] },
    { game_index: 448, version: [Object] }
  ],
  height: 12,
  held_items: [],
  id: 448,
  is_default: true,
  location_area_encounters: 'https://pokeapi.co/api/v2/pokemon/448/encounters',
  moves: [
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] },
    { move: [Object], version_group_details: [Array] }
  ],
  name: 'lucario',
  order: 555,
  past_types: [],
  species: {
    name: 'lucario',
    url: 'https://pokeapi.co/api/v2/pokemon-species/448/'
  },
  sprites: {
    back_default: 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/448.png',
    back_female: null,
    back_shiny: 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/448.png',
    back_shiny_female: null,
    front_default: 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/448.png',
    front_female: null,
    front_shiny: 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/448.png',
    front_shiny_female: null,
    other: { dream_world: [Object], 'official-artwork': [Object] },
    versions: {
      'generation-i': [Object],
      'generation-ii': [Object],
      'generation-iii': [Object],
      'generation-iv': [Object],
      'generation-v': [Object],
      'generation-vi': [Object],
      'generation-vii': [Object],
      'generation-viii': [Object]
    }
  },
  stats: [
    { base_stat: 70, effort: 0, stat: [Object] },
    { base_stat: 110, effort: 1, stat: [Object] },
    { base_stat: 70, effort: 0, stat: [Object] },
    { base_stat: 115, effort: 1, stat: [Object] },
    { base_stat: 70, effort: 0, stat: [Object] },
    { base_stat: 90, effort: 0, stat: [Object] }
  ],
  types: [ { slot: 1, type: [Object] }, { slot: 2, type: [Object] } ],
  weight: 540
}
Naramsim commented 3 years ago

It's normal, it's a Node feature for not displaying too much output in the console. The properties are there

GuikiPT commented 3 years ago

I will try to do that now and when I get something soon I say and close this problem

GuikiPT commented 3 years ago

Hi again, I tried to do what you said, and get the specific information from one of the pokedex api json variables, but he still "Object" both in the console, as in message.reply()

I used the same code base as this one on github, and only added a few variables to make interpletting easier, but still from "Object"

P.getPokemonByName('eevee') // with Promise
        .then(function(response) {
          console.log(response);

          const pokename = response.name;
          const pokeabilities = response.abilities;
          console.log(`Name: ${pokename}`);
          console.log(`Ability: ${pokeabilities}`);

          message.reply(pokeabilities);

        })

any way to overcome this? I also tried to do it using an https catch but give it to me in the same

image image

Naramsim commented 3 years ago

Of course it happens, you are trying to print an object in a template literal. If you really wanna have a JSON displayed you should JSON.stringify() it.

But showing a JSON in a discord message is a bit odd, no?

GuikiPT commented 3 years ago

thanks its that, its JSON.stingify()

thanks again xD