MCPcopy Create free account
hub / github.com/chokcoco/iCSS / fetchCategories

Function fetchCategories

website/app/page.tsx:84–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82
83 // 获取分类数据
84 const fetchCategories = async () => {
85 try {
86 const response = await fetch('/api/categories');
87 const data = await response.json();
88 console.log('Categories API response:', data);
89 // API 直接返回数组,不是 { categories: [...] } 格式
90 const categoriesData = Array.isArray(data) ? data : [];
91 console.log('Processed categories:', categoriesData);
92 setCategories(categoriesData);
93 } catch (err) {
94 console.error('Failed to fetch categories:', err);
95 setCategories(['全部']); // 设置默认值
96 }
97 };
98
99 useEffect(() => {
100 fetchArticles(1, false);

Callers 1

HomePageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected