Skip to content

Commit 82711f7

Browse files
committed
fix: extract text from blob
1 parent e8a9a1c commit 82711f7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

server/utils/docs/client.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ function createLoader(): (
8484
let url: URL
8585
try {
8686
url = new URL(specifier)
87-
} catch {
87+
} catch (e) {
88+
// eslint-disable-next-line no-console
89+
console.error(e)
8890
return undefined
8991
}
9092

@@ -94,7 +96,7 @@ function createLoader(): (
9496
}
9597

9698
try {
97-
const response = await $fetch.raw<string>(url.toString(), {
99+
const response = await $fetch.raw<Blob>(url.toString(), {
98100
method: 'GET',
99101
timeout: FETCH_TIMEOUT_MS,
100102
redirect: 'follow',
@@ -104,7 +106,7 @@ function createLoader(): (
104106
return undefined
105107
}
106108

107-
const content = response._data ?? ''
109+
const content = (await response._data?.text()) ?? ''
108110
const headers: Record<string, string> = {}
109111
for (const [key, value] of response.headers) {
110112
headers[key.toLowerCase()] = value
@@ -116,7 +118,9 @@ function createLoader(): (
116118
headers,
117119
content,
118120
}
119-
} catch {
121+
} catch (e) {
122+
// eslint-disable-next-line no-console
123+
console.error(e)
120124
return undefined
121125
}
122126
}
@@ -163,7 +167,9 @@ async function getTypesUrl(packageName: string, version: string): Promise<string
163167
timeout: FETCH_TIMEOUT_MS,
164168
})
165169
return response.headers.get('x-typescript-types')
166-
} catch {
170+
} catch (e) {
171+
// eslint-disable-next-line no-console
172+
console.error(e)
167173
return null
168174
}
169175
}

0 commit comments

Comments
 (0)