Appearance
useSharingApi Composable ​
File Information ​
- Path:
app/composables/api/useSharingApi.ts - Purpose: Share URL management operations API
- Category: Sharing API Composable
Overview ​
The useSharingApi composable provides functionality for managing share URLs including fetching share URLs, deleting multiple share URLs, and revoking individual share URLs.
Functions ​
fetchShareUrlsApi ​
Fetches list of share URLs for assets.
Signature:
typescript
fetchShareUrlsApi(body: any): Promise<any>Parameters:
body: any- Query parameters (workspace_id, page, per_page, filters, etc.)
Returns:
Promise<any>- Share URLs response
API Endpoint: GET /digital/list-share-assets-url?{queryString}
Usage:
typescript
const { fetchShareUrlsApi } = useSharingApi()
const { toQueryString } = useHelpers()
const shareUrls = await fetchShareUrlsApi({
workspace_id: workspaceId,
page: 1,
per_page: 20
})
// shareUrls contains array of share URL objectsdeleteShareUrlsApi ​
Deletes multiple share URLs.
Signature:
typescript
deleteShareUrlsApi(body: any): Promise<any>Parameters:
body: any- Delete request body (share_url_ids array, etc.)
Returns:
Promise<any>- Delete response
API Endpoint: POST /digital/delete-multiple-share-assets-url
Usage:
typescript
const { deleteShareUrlsApi } = useSharingApi()
await deleteShareUrlsApi({
share_url_ids: ['1', '2', '3']
})revokeShareUrlsApi ​
Revokes (deletes) a single share URL.
Signature:
typescript
revokeShareUrlsApi(body: any): Promise<any>Parameters:
body: any- Revoke request body (share_url_id, etc.)
Returns:
Promise<any>- Revoke response
API Endpoint: POST /digital/delete-share-assets-url
Usage:
typescript
const { revokeShareUrlsApi } = useSharingApi()
await revokeShareUrlsApi({
share_url_id: '123'
})Error Handling ​
All functions include error logging:
typescript
catch (error: any) {
console.error("[ShareAPI] {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 Share URLs ​
typescript
const { fetchShareUrlsApi } = useSharingApi()
const loadShareUrls = async (page: number = 1) => {
try {
const shareUrls = await fetchShareUrlsApi({
workspace_id: workspaceId,
page,
per_page: 20
})
// Display share URLs...
} catch (error) {
console.error('Failed to load share URLs:', error)
}
}Delete Multiple Share URLs ​
typescript
const { deleteShareUrlsApi } = useSharingApi()
const deleteSelected = async (selectedIds: string[]) => {
try {
await deleteShareUrlsApi({
share_url_ids: selectedIds
})
snackbar.showSuccess('Share URLs deleted successfully')
} catch (error) {
snackbar.showError('Failed to delete share URLs')
}
}Revoke Share URL ​
typescript
const { revokeShareUrlsApi } = useSharingApi()
const revokeShare = async (shareUrlId: string) => {
try {
await revokeShareUrlsApi({
share_url_id: shareUrlId
})
snackbar.showSuccess('Share URL revoked')
} catch (error) {
snackbar.showError('Failed to revoke share URL')
}
}Related Documentation ​
- Sharing Feature - Sharing feature documentation
- Share Dialog API - Share dialog operations
- External Share API - External sharing operations