Skip to content

Commit

Permalink
Fix: use request type error, adjust type definition for consistency (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
crywolfx authored Jul 18, 2024
1 parent 7ca553d commit a7b7791
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/plugin-request/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { AxiosRequestConfig } from 'axios';
import { request } from './request.js';

interface RequestResult<R, P extends any[]> extends Result<R, P> {
request: (...args: P) => Promise<R>;
request: Result<R, P>['run'];
requestAsync: Result<R, P>['runAsync'];
}

export function useRequest<TData, TParams extends any[] = []>(
Expand Down Expand Up @@ -35,6 +36,8 @@ export function useRequest<TData, TParams extends any[] = []>(
...req,
// Modify ahooks' useRequest `run` as `request`
request: req.run,
// Modify ahooks' useRequest `runAsync` as `requestAsync`
requestAsync: req.runAsync,
} as RequestResult<TData, TParams>;
}

Expand Down

0 comments on commit a7b7791

Please sign in to comment.