Last active
January 24, 2018 04:53
-
-
Save pbabbott/edcb69dddd8468b077c447144cb1127d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import apiClient from 'somewhere-else'; | |
const pokemonCache = {}; | |
export function getRawPokemonData(id){ | |
let cachedPokemon = pokemonCache[id]; | |
if (cachedPokemon){ | |
return new Promise((resolve, reject) =>{ | |
resolve(cachedPokemon); | |
}); | |
} else{ | |
return apiClient.get('/pokemon/' + id).then(r => { | |
pokemonCache[id] = r.data; | |
return r.data; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment