Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useFetch): mark isFinished, isFetching readonly #3616

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/core/useFetch/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { EventHookOn, Fn, MaybeRefOrGetter, Stoppable } from '@vueuse/shared'
import { containsProp, createEventHook, toRef, toValue, until, useTimeoutFn } from '@vueuse/shared'
import type { ComputedRef, Ref } from 'vue-demi'
import { computed, isRef, ref, shallowRef, watch } from 'vue-demi'
import { computed, isRef, readonly, ref, shallowRef, watch } from 'vue-demi'
import { defaultWindow } from '../_configurable'

export interface UseFetchReturn<T> {
/**
* Indicates if the fetch request has finished
*/
isFinished: Ref<boolean>
isFinished: Readonly<Ref<boolean>>

/**
* The statusCode of the HTTP fetch response
Expand All @@ -33,7 +33,7 @@ export interface UseFetchReturn<T> {
/**
* Indicates if the request is currently being fetched.
*/
isFetching: Ref<boolean>
isFetching: Readonly<Ref<boolean>>

/**
* Indicates if the fetch request is able to be aborted
Expand Down Expand Up @@ -528,12 +528,12 @@ export function useFetch<T>(url: MaybeRefOrGetter<string>, ...args: any[]): UseF
)

const shell: UseFetchReturn<T> = {
isFinished,
isFinished: readonly(isFinished),
isFetching: readonly(isFetching),
statusCode,
response,
error,
data,
isFetching,
canAbort,
aborted,
abort,
Expand Down