mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
Merge branch 'main' into docs/kit
This commit is contained in:
commit
935bee66e7
@ -69,15 +69,6 @@ export function useFetch<
|
||||
arg2?: string
|
||||
) {
|
||||
const [opts = {}, autoKey] = typeof arg1 === 'string' ? [{}, arg1] : [arg1, arg2]
|
||||
const _key = opts.key || hash([autoKey, unref(opts.baseURL), typeof request === 'string' ? request : '', unref(opts.params || opts.query)])
|
||||
if (!_key || typeof _key !== 'string') {
|
||||
throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key)
|
||||
}
|
||||
if (!request) {
|
||||
throw new Error('[nuxt] [useFetch] request is missing.')
|
||||
}
|
||||
|
||||
const key = _key === autoKey ? '$f' + _key : _key
|
||||
|
||||
const _request = computed(() => {
|
||||
let r = request
|
||||
@ -87,6 +78,16 @@ export function useFetch<
|
||||
return unref(r)
|
||||
})
|
||||
|
||||
const _key = opts.key || hash([autoKey, unref(opts.baseURL), typeof _request.value === 'string' ? _request.value : '', unref(opts.params || opts.query)])
|
||||
if (!_key || typeof _key !== 'string') {
|
||||
throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key)
|
||||
}
|
||||
if (!request) {
|
||||
throw new Error('[nuxt] [useFetch] request is missing.')
|
||||
}
|
||||
|
||||
const key = _key === autoKey ? '$f' + _key : _key
|
||||
|
||||
if (!opts.baseURL && typeof _request.value === 'string' && _request.value.startsWith('//')) {
|
||||
throw new Error('[nuxt] [useFetch] the request URL must not start with "//".')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user