Cache in pokedex, cache less in whos-that-pokemon

This commit is contained in:
Daniel Odendahl Jr
2018-07-09 18:59:44 +00:00
parent c9cdb122a6
commit d6d1bf2b04
3 changed files with 31 additions and 11 deletions
+4 -1
View File
@@ -53,7 +53,10 @@ module.exports = class WhosThatPokemonCommand extends Command {
async fetchPokemon(pokemon) {
if (this.cache.has(pokemon)) return this.cache.get(pokemon);
const { body } = await request.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}/`);
this.cache.set(body.id, body);
this.cache.set(body.id, {
id: body.id,
names: body.names
});
return body;
}