1
0
mirror of https://github.com/mgerb/classic-wow-forums synced 2026-01-11 09:32:51 +00:00
Files
classic-wow-forums/client/app/services/category.service.ts

20 lines
473 B
TypeScript

import { cloneDeep } from 'lodash';
import axios from '../axios/axios';
import { CategoryModel } from '../model';
let categoryCache: CategoryModel[];
const getCategories = async () => {
// return cache if it exists
if (categoryCache) {
return Promise.resolve(cloneDeep(categoryCache));
}
const res = await axios.get('/api/category');
categoryCache = cloneDeep(res.data.data);
return res.data.data;
};
export const CategoryService = {
getCategories,
};