Appearance
useFolderApi Composable ​
File Information ​
- Path:
app/composables/api/useFolderApi.ts - Purpose: Folder/category operations API
- Category: Content API Composable
Overview ​
The useFolderApi composable provides functionality for fetching folders/categories and their associated files.
Functions ​
getAllFolders ​
Fetches all folders/categories for a workspace.
Signature:
typescript
getAllFolders(
workspace: string,
isSubFolder: boolean
): Promise<any>Parameters:
workspace: string- Workspace IDisSubFolder: boolean- Whether to include subfolders
Returns:
Promise<any>- Folders response
API Endpoint: GET /digital/category-list?workspace_id={workspace}&subfolder_list={0|1}
Usage:
typescript
const { getAllFolders } = useFolderApi()
// Get folders without subfolders
const folders = await getAllFolders(workspaceId, false)
// Get folders with subfolders
const foldersWithSubs = await getAllFolders(workspaceId, true)fetchFolderDetails ​
Fetches detailed information about a folder including its files.
Signature:
typescript
fetchFolderDetails(body: any): Promise<any>Parameters:
body: any- Query parameters (folder_id, workspace_id, page, per_page, filters, etc.)
Returns:
Promise<any>- Folder details with files
API Endpoint: GET /digital/view-files-with-category?{queryString}
Usage:
typescript
const { fetchFolderDetails } = useFolderApi()
const { toQueryString } = useHelpers()
const details = await fetchFolderDetails({
category_id: folderId,
workspace_id: workspaceId,
page: 1,
per_page: 20
})
// details contains folder info and filesError Handling ​
All functions include error logging:
typescript
catch (error: any) {
console.error("[FolderAPI] {functionName} - Error:", error)
throw error
}Integration with API Client ​
The composable uses the global $api client:
typescript
const { $api } = useNuxtApp()
const { toQueryString } = useHelpers()Use Cases ​
List Folders ​
typescript
const { getAllFolders } = useFolderApi()
const loadFolders = async (includeSubfolders: boolean) => {
try {
const folders = await getAllFolders(workspaceId, includeSubfolders)
// Display folders...
} catch (error) {
console.error('Failed to load folders:', error)
}
}View Folder Contents ​
typescript
const { fetchFolderDetails } = useFolderApi()
const loadFolderFiles = async (folderId: string, page: number = 1) => {
try {
const details = await fetchFolderDetails({
category_id: folderId,
workspace_id: workspaceId,
page,
per_page: 20
})
// Display folder files...
} catch (error) {
console.error('Failed to load folder:', error)
}
}Related Documentation ​
- Folder Management - Folder management feature
- API Client - API client configuration