Skip to content

Instantly share code, notes, and snippets.

@anchetaWern
Created July 12, 2019 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchetaWern/ea69241ab616ab17bb518e53ce3be593 to your computer and use it in GitHub Desktop.
Save anchetaWern/ea69241ab616ab17bb518e53ce3be593 to your computer and use it in GitHub Desktop.
Pokedex Bot: Pokemon endpoint
if (pokemon_endpoint.indexOf(specs) !== -1) {
const { data } = await axios_instance.get(`/pokemon/${pokemon}`);
let fulfillmentText;
const id = String(data.id).padStart(3, '0');
const value = (specs == 'abilities') ? data.abilities.map(item => item.ability.name).join(', ') : data.moves.map(item => item.move.name).join(', ');
fulfillmentText = `The ${specs} of ${pokemon} are: ${value}`;
Object.assign(response_obj, { fulfillmentText });
if (specs == 'photo') {
Object.assign(response_obj, {
fulfillmentText: pokemon,
payload: {
is_image: true,
url: `https://www.pkparaiso.com/imagenes/xy/sprites/global_link/${id}.png`
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment