@thunderstorefront/sdk
Version:
Create Nuxt extendable layer with this GitHub template.
18 lines (13 loc) • 408 B
text/typescript
import type { Category } from '@thunderstorefront/types';
export interface UseCategoryApi<TCategory = Category> {
fetchCategory: (slug: string) => Promise<TCategory>;
}
export function useCategoryApi(): UseCategoryApi {
const client = useClient();
async function fetchCategory(id: string): Promise<Category> {
return await client(`/api/category/${id}`);
}
return {
fetchCategory
};
}