mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): add reason when aborting request in useFetch
(#28517)
This commit is contained in:
parent
c4ae151de5
commit
fe954c434c
@ -155,7 +155,7 @@ export function useFetch<
|
||||
let controller: AbortController
|
||||
|
||||
const asyncData = useAsyncData<_ResT, ErrorT, DataT, PickKeys, DefaultT>(key, () => {
|
||||
controller?.abort?.()
|
||||
controller?.abort?.('Request aborted as another request to the same endpoint was initiated.')
|
||||
controller = typeof AbortController !== 'undefined' ? new AbortController() : {} as AbortController
|
||||
|
||||
/**
|
||||
@ -167,7 +167,7 @@ export function useFetch<
|
||||
const timeoutLength = toValue(opts.timeout)
|
||||
let timeoutId: NodeJS.Timeout
|
||||
if (timeoutLength) {
|
||||
timeoutId = setTimeout(() => controller.abort(), timeoutLength)
|
||||
timeoutId = setTimeout(() => controller.abort('Request aborted due to timeout.'), timeoutLength)
|
||||
controller.signal.onabort = () => clearTimeout(timeoutId)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user