Skip to content

Commit

Permalink
fix: always return $fetch and $fetchState
Browse files Browse the repository at this point in the history
closes #372
  • Loading branch information
danielroe committed Feb 15, 2021
1 parent 7969357 commit e0a9cf4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export const useFetch = (callback: Fetch) => {
onBeforeMount(() => !vm._hydrated && callFetches.call(vm))

if (process.server || !isSsrHydration(vm)) {
if (process.client && isFullStatic) return loadFullStatic(vm)
if (process.client && isFullStatic) loadFullStatic(vm)
return result()
}

Expand Down
22 changes: 22 additions & 0 deletions test/tsd/fetch.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expectType } from 'tsd'

import { useFetch } from '../..'

expectType<{
fetch: () => void
$fetch: () => void
fetchState: {
error: Error | null
pending: boolean
timestamp: number
}
$fetchState: {
error: Error | null
pending: boolean
timestamp: number
}
}>(
useFetch(async () => {
//
})
)

1 comment on commit e0a9cf4

@vercel
Copy link

@vercel vercel bot commented on e0a9cf4 Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.