Browse Source
feat(table): support asynchrony in beforeFetch and afterFetch (#827)
pull/832/head
SUPER_AI
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
2 deletions
-
src/components/Table/src/hooks/useDataSource.ts
|
|
|
@ -203,7 +203,7 @@ export function useDataSource( |
|
|
|
...(opt?.filterInfo ?? {}), |
|
|
|
}; |
|
|
|
if (beforeFetch && isFunction(beforeFetch)) { |
|
|
|
params = beforeFetch(params) || params; |
|
|
|
params = (await beforeFetch(params)) || params; |
|
|
|
} |
|
|
|
|
|
|
|
const res = await api(params); |
|
|
|
@ -225,7 +225,7 @@ export function useDataSource( |
|
|
|
} |
|
|
|
|
|
|
|
if (afterFetch && isFunction(afterFetch)) { |
|
|
|
resultItems = afterFetch(resultItems) || resultItems; |
|
|
|
resultItems = (await afterFetch(resultItems)) || resultItems; |
|
|
|
} |
|
|
|
dataSourceRef.value = resultItems; |
|
|
|
setPagination({ |
|
|
|
|