refactor(deps): migrate to nuxt v4
This commit is contained in:
21
app/composables/useFetchWrapped.ts
Normal file
21
app/composables/useFetchWrapped.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useFormPayload } from '~/composables/useFormPayload'
|
||||
|
||||
export const useFetchWrapped = <TypeReq, TypeResp>(
|
||||
action: string,
|
||||
payload?: TypeReq,
|
||||
options?: {
|
||||
method?: 'GET' | 'POST'
|
||||
headers?: Record<string, string>
|
||||
baseURL?: string
|
||||
}
|
||||
) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
return $fetch<TypeResp>('/', {
|
||||
baseURL: options?.baseURL || runtimeConfig.public.API_BASE,
|
||||
method: options?.method || 'POST',
|
||||
query: {
|
||||
s: action,
|
||||
},
|
||||
body: useFormPayload(payload as object),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user