(url: MaybeRefOrGetter<string>, ...args: any[])
| 279 | const _fetchOptions = config.fetchOptions || {} |
| 280 | |
| 281 | function useFactoryFetch(url: MaybeRefOrGetter<string>, ...args: any[]) { |
| 282 | const computedUrl = computed(() => { |
| 283 | const baseUrl = toValue(config.baseUrl) |
| 284 | const targetUrl = toValue(url) |
| 285 | |
| 286 | return (baseUrl && !isAbsoluteURL(targetUrl)) |
| 287 | ? joinPaths(baseUrl, targetUrl) |
| 288 | : targetUrl |
| 289 | }) |
| 290 | |
| 291 | let options = _options |
| 292 | let fetchOptions = _fetchOptions |
| 293 | |
| 294 | // Merge properties into a single object |
| 295 | if (args.length > 0) { |
| 296 | if (isFetchOptions(args[0])) { |
| 297 | options = { |
| 298 | ...options, |
| 299 | ...args[0], |
| 300 | beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch), |
| 301 | afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch), |
| 302 | onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError), |
| 303 | } |
| 304 | } |
| 305 | else { |
| 306 | fetchOptions = { |
| 307 | ...fetchOptions, |
| 308 | ...args[0], |
| 309 | headers: { |
| 310 | ...(headersToObject(fetchOptions.headers) || {}), |
| 311 | ...(headersToObject(args[0].headers) || {}), |
| 312 | }, |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | if (args.length > 1 && isFetchOptions(args[1])) { |
| 318 | options = { |
| 319 | ...options, |
| 320 | ...args[1], |
| 321 | beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch), |
| 322 | afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch), |
| 323 | onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError), |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | return useFetch(computedUrl, fetchOptions, options) |
| 328 | } |
| 329 | |
| 330 | return useFactoryFetch as typeof useFetch |
| 331 | } |
nothing calls this directly
no test coverage detected