mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-10 17:12:48 +00:00
20 lines
472 B
TypeScript
20 lines
472 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,
|
|
};
|