mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(nuxt): include method when creating useFetch
auto key (#23086)
This commit is contained in:
parent
48fa30af92
commit
aa73cbeaf9
@ -1,6 +1,6 @@
|
|||||||
import type { FetchError, FetchOptions } from 'ofetch'
|
import type { FetchError, FetchOptions } from 'ofetch'
|
||||||
import type { NitroFetchRequest, TypedInternalResponse, AvailableRouterMethod as _AvailableRouterMethod } from 'nitropack'
|
import type { NitroFetchRequest, TypedInternalResponse, AvailableRouterMethod as _AvailableRouterMethod } from 'nitropack'
|
||||||
import type { Ref } from 'vue'
|
import type { MaybeRef, Ref } from 'vue'
|
||||||
import { computed, reactive, unref } from 'vue'
|
import { computed, reactive, unref } from 'vue'
|
||||||
import { hash } from 'ohash'
|
import { hash } from 'ohash'
|
||||||
import { useRequestFetch } from './ssr'
|
import { useRequestFetch } from './ssr'
|
||||||
@ -85,7 +85,7 @@ export function useFetch<
|
|||||||
return unref(r)
|
return unref(r)
|
||||||
})
|
})
|
||||||
|
|
||||||
const _key = opts.key || hash([autoKey, unref(opts.baseURL), typeof _request.value === 'string' ? _request.value : '', unref(opts.params || opts.query)])
|
const _key = opts.key || hash([autoKey, unref(opts.method as MaybeRef<string | undefined> | undefined)?.toUpperCase() || 'GET', unref(opts.baseURL), typeof _request.value === 'string' ? _request.value : '', unref(opts.params || opts.query)])
|
||||||
if (!_key || typeof _key !== 'string') {
|
if (!_key || typeof _key !== 'string') {
|
||||||
throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key)
|
throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user