kit
GitHub
npm
Preparing search index...
@knitkode/api
swr-mutation
createSwrMutationApi
Function createSwrMutationApi
createSwrMutationApi
<
TEndpoints
extends
Endpoints
>
(
...
args
:
[
apiName
:
string
,
baseUrl
:
string
,
defaultOptions
?:
ClientOptions
,
]
,
)
:
Api
.
Client
<
TEndpoints
>
&
{
useDelete
:
KitApiMethodHookSWR
<
"useDelete"
,
TEndpoints
>
;
usePatch
:
KitApiMethodHookSWR
<
"usePatch"
,
TEndpoints
>
;
usePost
:
KitApiMethodHookSWR
<
"usePost"
,
TEndpoints
>
;
usePut
:
KitApiMethodHookSWR
<
"usePut"
,
TEndpoints
>
;
}
&
{
use
:
<
TEndpoint
extends
string
>
(
endpoint
:
TEndpoint
,
options
?:
EndpointOptions
<
TEndpoints
,
TEndpoint
,
"get"
>
,
swrConfig
?:
ConfigurationExtended
<
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"ok"
>
,
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"fail"
>
,
BareFetcher
<
any
>
,
>
,
)
=>
SWRResponse
<
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"ok"
>
,
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"fail"
>
,
any
,
>
;
}
It creates an api client extended with auto-generated SWR wrapper hooks
Type Parameters
TEndpoints
extends
Endpoints
Parameters
...
args
:
[
apiName
:
string
,
baseUrl
:
string
,
defaultOptions
?:
ClientOptions
]
Returns
Api
.
Client
<
TEndpoints
>
&
{
useDelete
:
KitApiMethodHookSWR
<
"useDelete"
,
TEndpoints
>
;
usePatch
:
KitApiMethodHookSWR
<
"usePatch"
,
TEndpoints
>
;
usePost
:
KitApiMethodHookSWR
<
"usePost"
,
TEndpoints
>
;
usePut
:
KitApiMethodHookSWR
<
"usePut"
,
TEndpoints
>
;
}
&
{
use
:
<
TEndpoint
extends
string
>
(
endpoint
:
TEndpoint
,
options
?:
EndpointOptions
<
TEndpoints
,
TEndpoint
,
"get"
>
,
swrConfig
?:
ConfigurationExtended
<
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"ok"
>
,
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"fail"
>
,
BareFetcher
<
any
>
,
>
,
)
=>
SWRResponse
<
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"ok"
>
,
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"fail"
>
,
any
,
>
;
}
useDelete
:
KitApiMethodHookSWR
<
"useDelete"
,
TEndpoints
>
usePatch
:
KitApiMethodHookSWR
<
"usePatch"
,
TEndpoints
>
usePost
:
KitApiMethodHookSWR
<
"usePost"
,
TEndpoints
>
usePut
:
KitApiMethodHookSWR
<
"usePut"
,
TEndpoints
>
use
:
<
TEndpoint
extends
string
>
(
endpoint
:
TEndpoint
,
options
?:
EndpointOptions
<
TEndpoints
,
TEndpoint
,
"get"
>
,
swrConfig
?:
ConfigurationExtended
<
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"ok"
>
,
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"fail"
>
,
BareFetcher
<
any
>
,
>
,
)
=>
SWRResponse
<
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"ok"
>
,
GetDataType
<
TEndpoints
,
TEndpoint
,
"get"
,
"fail"
>
,
any
,
>
Settings
Member Visibility
Protected
Inherited
External
Theme
OS
Light
Dark
GitHub
npm
kit
Loading...
It creates an api client extended with auto-generated SWR wrapper hooks