Replies: 4 comments 2 replies
-
export interface HogeEndpointRequest {
id: string
date: string
page: number
}
export interface HogeEndpointResponse {
data: Hoge[]
}
// Use case
const useSomeEndpoint = ({id, ..body}: HogeEndpointRequest & { id: string }) => {
return useFetch<HogeEndpointResponse>(m2mHoge.someEndpoint({id}), ....)
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
JSON scheme |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
1 const getHogeEndpointConfig = () => {
return {
url: ({ id }) => `/api/v1/hoge/${id}`,
method: 'GET'
] as const
}
const useGetHogeEndpoint = ({ id }) => {
const config = getHogeEndpointConfig()
return useFetch(config.url({ id }), {method: config.method })
}2 const getHogeEndpointConfig = () => {
return {
url: ({ id }) => `/api/v1/hoge/${id}`,
options: { method: 'GET' }
}
}
const useGetHogeEndpoint = ({ id }) => {
const config = getHogeEndpointConfig()
return useFetch(config.url({ id }), { ...config.options })
}3 const getHogeEndpoint = ({ id }) => {
return `/api/v1/hoge/${id}`,
}
getHogeEndpoint.method = "GET"
const useGetHogeEndpoint = ({ id }) => {
return useFetch(getHogeEndpoint({ id }), { method: getHogeEndpoint.method })
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions