Spaces:
Paused
Paused
Download node_modules/@huggingface/hub/src/lib/collection-info.ts from Leon4gr45/UserSyncFrontend: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40huggingface/hub/src/lib/collection-info.ts
- Command line
-
hf download hf://spaces/Leon4gr45/UserSyncFrontend/node_modules/@huggingface/hub/src/lib/collection-info.ts
-
curl -L -o collection-info.ts https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40huggingface/hub/src/lib/collection-info.ts
1.03 kB
| import { HUB_URL } from "../consts"; | |
| import { createApiError } from "../error"; | |
| import type { ApiCollectionInfo } from "../types/api/api-collection"; | |
| import type { CredentialsParams } from "../types/public"; | |
| import { checkCredentials } from "../utils/checkCredentials"; | |
| export async function collectionInfo( | |
| params: { | |
| /** | |
| * The slug of the collection. | |
| */ | |
| slug: string; | |
| hubUrl?: string; | |
| /** | |
| * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. | |
| */ | |
| fetch?: typeof fetch; | |
| } & Partial<CredentialsParams>, | |
| ): Promise<ApiCollectionInfo & { position: number; shareUrl: string }> { | |
| const accessToken = checkCredentials(params); | |
| const res = await (params.fetch ?? fetch)(`${params.hubUrl ?? HUB_URL}/api/collections/${params.slug}`, { | |
| headers: { | |
| "Content-Type": "application/json", | |
| ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : undefined), | |
| }, | |
| }); | |
| if (!res.ok) { | |
| throw await createApiError(res); | |
| } | |
| return await res.json(); | |
| } | |