MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchCollectionNameDirect

Function fetchCollectionNameDirect

apps/sim/connectors/webflow/webflow.ts:425–456  ·  view source on GitHub ↗

* Fetches a collection's display name directly from the API.

(
  accessToken: string,
  collectionId: string
)

Source from the content-addressed store, hash-verified

423 * Fetches a collection's display name directly from the API.
424 */
425async 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}

Callers 2

webflow.tsFile · 0.85
fetchCollectionNameFunction · 0.85

Calls 3

fetchWithRetryFunction · 0.90
toErrorFunction · 0.90
warnMethod · 0.65

Tested by

no test coverage detected