Skip to content

Commit ba743b2

Browse files
authored
docs(table): fix ajax demo (#4639)
1 parent 6e85fd9 commit ba743b2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

components/table/demo/ajax.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ This example shows how to fetch and present data from a remote server, and how t
3838
import type { TableProps } from 'ant-design-vue';
3939
import { usePagination } from 'vue-request';
4040
import { computed, defineComponent } from 'vue';
41+
import axios from 'axios';
4142
const columns = [
4243
{
4344
title: 'Name',
@@ -76,7 +77,7 @@ type APIResult = {
7677
};
7778
7879
const queryData = (params: APIParams) => {
79-
return `https://randomuser.me/api?noinfo&${new URLSearchParams(params)}`;
80+
return axios.get<APIResult>('https://randomuser.me/api?noinfo', { params });
8081
};
8182
8283
export default defineComponent({
@@ -87,8 +88,8 @@ export default defineComponent({
8788
loading,
8889
current,
8990
pageSize,
90-
} = usePagination<APIResult>(queryData, {
91-
formatResult: res => res.results,
91+
} = usePagination(queryData, {
92+
formatResult: res => res.data.results,
9293
pagination: {
9394
currentKey: 'page',
9495
pageSizeKey: 'results',

0 commit comments

Comments
 (0)