* Fetches a collection's display name directly from the API.
( accessToken: string, collectionId: string )
| 423 | * Fetches a collection's display name directly from the API. |
| 424 | */ |
| 425 | async function fetchCollectionNameDirect( |
| 426 | accessToken: string, |
| 427 | collectionId: string |
| 428 | ): Promise<string> { |
| 429 | try { |
| 430 | const url = `${WEBFLOW_API}/collections/${collectionId}` |
| 431 | const response = await fetchWithRetry(url, { |
| 432 | method: 'GET', |
| 433 | headers: { |
| 434 | Authorization: `Bearer ${accessToken}`, |
| 435 | 'accept-version': '2.0.0', |
| 436 | }, |
| 437 | }) |
| 438 | |
| 439 | if (!response.ok) { |
| 440 | logger.warn('Failed to fetch collection name', { |
| 441 | collectionId, |
| 442 | status: response.status, |
| 443 | }) |
| 444 | return collectionId |
| 445 | } |
| 446 | |
| 447 | const data = (await response.json()) as WebflowCollection |
| 448 | return data.displayName || data.slug || collectionId |
| 449 | } catch (error) { |
| 450 | logger.warn('Error fetching collection name', { |
| 451 | collectionId, |
| 452 | error: toError(error).message, |
| 453 | }) |
| 454 | return collectionId |
| 455 | } |
| 456 | } |
no test coverage detected