[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: handle non-existent org

+10 -4
+10 -4
app/composables/useNpmRegistry.ts
··· 250 250 /** 251 251 * Fetch all package names in an npm organization 252 252 * Uses the /-/org/{org}/package endpoint 253 + * Returns empty array if org doesn't exist or has no packages 253 254 */ 254 255 async function fetchOrgPackageNames(orgName: string): Promise<string[]> { 255 - const data = await $fetch<Record<string, string>>( 256 - `${NPM_REGISTRY}/-/org/${encodeURIComponent(orgName)}/package`, 257 - ) 258 - return Object.keys(data) 256 + try { 257 + const data = await $fetch<Record<string, string>>( 258 + `${NPM_REGISTRY}/-/org/${encodeURIComponent(orgName)}/package`, 259 + ) 260 + return Object.keys(data) 261 + } catch { 262 + // Org doesn't exist or has no packages 263 + return [] 264 + } 259 265 } 260 266 261 267 /**