Skip to content

Commit 49773e1

Browse files
committed
fix: $fetch type errors
1 parent 95bc739 commit 49773e1

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

app/composables/useConnector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export const useConnector = createSharedComposable(function useConnector() {
200200
if (!config.value) return null
201201

202202
try {
203-
const response = await $fetch(`${baseUrl.value}${path}`, {
203+
const response = await ($fetch as Function)(`${baseUrl.value}${path}`, {
204204
method: options.method ?? 'GET',
205205
headers: {
206206
Authorization: `Bearer ${config.value.token}`,

server/plugins/fetch-cache.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ export default defineNitroPlugin(nitroApp => {
6464
ttl: number = FETCH_CACHE_DEFAULT_TTL,
6565
): Promise<CachedFetchResult<T>> => {
6666
// Check if this URL should be cached
67+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
68+
const _fetch = $fetch as any
6769
if (!isAllowedDomain(url)) {
68-
const data = (await $fetch(url, options)) as T
70+
const data = (await _fetch(url, options)) as T
6971
return { data, isStale: false, cachedAt: null }
7072
}
7173

@@ -108,7 +110,7 @@ export default defineNitroPlugin(nitroApp => {
108110
event.waitUntil(
109111
(async () => {
110112
try {
111-
const freshData = (await $fetch(url, options as Parameters<typeof $fetch>[1])) as T
113+
const freshData = (await _fetch(url, options)) as T
112114
const entry: CachedFetchEntry<T> = {
113115
data: freshData,
114116
status: 200,
@@ -140,7 +142,7 @@ export default defineNitroPlugin(nitroApp => {
140142
console.log(`[fetch-cache] MISS: ${url}`)
141143
}
142144

143-
const data = (await $fetch(url, options as Parameters<typeof $fetch>[1])) as T
145+
const data = (await _fetch(url, options)) as T
144146
const cachedAt = Date.now()
145147

146148
// Defer cache write to background via waitUntil for faster response

server/utils/docs/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ async function getTypesUrl(packageName: string, version: string): Promise<string
162162
const url = `https://esm.sh/${packageName}@${version}`
163163

164164
try {
165-
const response = await $fetch.raw(url, {
165+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
166+
const response = await ($fetch.raw as any)(url, {
166167
method: 'HEAD',
167168
timeout: FETCH_TIMEOUT_MS,
168169
})

0 commit comments

Comments
 (0)