Commit 749ba5c1daf459625518937c239787b756c0a780
Committed by
GitHub
1 parent
d38ff667
feat(table): support asynchrony in beforeFetch and afterFetch (#827)
Showing
1 changed file
with
2 additions
and
2 deletions
src/components/Table/src/hooks/useDataSource.ts
@@ -203,7 +203,7 @@ export function useDataSource( | @@ -203,7 +203,7 @@ export function useDataSource( | ||
203 | ...(opt?.filterInfo ?? {}), | 203 | ...(opt?.filterInfo ?? {}), |
204 | }; | 204 | }; |
205 | if (beforeFetch && isFunction(beforeFetch)) { | 205 | if (beforeFetch && isFunction(beforeFetch)) { |
206 | - params = beforeFetch(params) || params; | 206 | + params = (await beforeFetch(params)) || params; |
207 | } | 207 | } |
208 | 208 | ||
209 | const res = await api(params); | 209 | const res = await api(params); |
@@ -225,7 +225,7 @@ export function useDataSource( | @@ -225,7 +225,7 @@ export function useDataSource( | ||
225 | } | 225 | } |
226 | 226 | ||
227 | if (afterFetch && isFunction(afterFetch)) { | 227 | if (afterFetch && isFunction(afterFetch)) { |
228 | - resultItems = afterFetch(resultItems) || resultItems; | 228 | + resultItems = (await afterFetch(resultItems)) || resultItems; |
229 | } | 229 | } |
230 | dataSourceRef.value = resultItems; | 230 | dataSourceRef.value = resultItems; |
231 | setPagination({ | 231 | setPagination({ |