1
Opportunity 282 天前
这种?
``` export type Client = typeof client; export type ApiCall<T> = (client: Client) => Promise<T>; export function useApi() { return async function <T extends { data: any; error?: any; response: Response; }>(apiCall: ApiCall<T>): Promise<Awaited<ReturnType<ApiCall<T>>>['data']> { const response = await apiCall(client); return response.data; }; } client.GET('/url2') const api = useApi(); const r = await api(client => client.GET('/url2')) ``` |