Skip to content

Commit

Permalink
Examples: fix type in axios-typescript example (#2552)
Browse files Browse the repository at this point in the history
Examles: fix type in axios-typescript example

close #2541
  • Loading branch information
daochouwangu authored Apr 7, 2023
1 parent af90b11 commit c09d200
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/axios-typescript/libs/useRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function useRequest<Data = unknown, Error = unknown>(
isValidating,
mutate
} = useSWR<AxiosResponse<Data>, AxiosError<Error>>(
request && JSON.stringify(request),
request,
/**
* NOTE: Typescript thinks `request` can be `null` here, but the fetcher
* function is actually only called by `useSWR` when it isn't.
Expand All @@ -46,7 +46,7 @@ export default function useRequest<Data = unknown, Error = unknown>(
config: request!,
headers: {},
data: fallbackData
}
} as AxiosResponse<Data>
}
)

Expand Down
2 changes: 1 addition & 1 deletion examples/axios/libs/useRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios from 'axios'

export default function useRequest(request, { fallbackData, ...config } = {}) {
return useSWR(
request && JSON.stringify(request),
request,
() => axios(request || {}).then(response => response.data),
{
...config,
Expand Down

0 comments on commit c09d200

Please sign in to comment.