Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const getData = (url: string) => {
- return new Promise((resolve, reject) => {
- findInCache(url)
- .then((cached: string | null) => {
- if (cached) {
- resolve(cached);
- }
- })
- .then(() => {
- axios
- .get(url)
- .then(({data}) => {
- setCache(url, data, TTL);
- resolve(data);
- })
- .catch(e => reject(e));
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement