umi#request TypeScript Examples

The following examples show how to use umi#request. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx    From umi-micro-apps with MIT License 6 votes vote down vote up
UserList = (props: any) => {
  const { shopId } = props;
  const { data = [] } = useRequest(() => request(`/api/user/list?shopId=${shopId}`));

  const columns = [
    {
      dataIndex: 'id',
      title: 'ID',
    },
    {
      dataIndex: 'name',
      title: '姓名',
    },
    {
      dataIndex: 'address',
      title: '住址',
    },
    {
      dataIndex: 'id',
      title: '操作',
      render: (id: string) => (
        <Link to={`/${id}`}>详情</Link>
      )
    },
  ];

  return (
    <div>
      <h1 style={{ marginBottom: 24 }}>用户列表</h1>

      <Table rowKey="id" columns={columns} dataSource={data} />

    </div>
  );
}
Example #2
Source File: index.ts    From scorpio-h5-design with MIT License 6 votes vote down vote up
export async function getCategoryList(data: {
  current?: number;
  pageSize?: number;
}, form: {
  name?: string;
}) {
  return request(`${HOST}/category/list`, {
    method: 'post',
    data: {
      ...data,
      ...form,
    },
  });
}
Example #3
Source File: service.ts    From ant-design-pro-V5-multitab with MIT License 6 votes vote down vote up
export async function removeRule(params: { key: number[] }) {
  return request('/api/rule', {
    method: 'POST',
    data: {
      ...params,
      method: 'delete',
    },
  });
}
Example #4
Source File: api.ts    From anew-server with MIT License 6 votes vote down vote up
export async function createApi(body: API.ApiParams, options?: { [key: string]: any }) {
  return request<API.Result>('/api/v1/api/create', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}
Example #5
Source File: service.ts    From ant-design-pro-V4 with MIT License 5 votes vote down vote up
export async function queryProjectNotice(): Promise<{ data: NoticeType[] }> {
  return request('/api/project/notice');
}
Example #6
Source File: index.ts    From scorpio-h5-design with MIT License 5 votes vote down vote up
export async function addCategory(data: {
  name: string;
}) {
  return request(`${HOST}/category/add`, {
    method: 'post',
    data,
  });
}
Example #7
Source File: service.ts    From ant-design-pro-V5-multitab with MIT License 5 votes vote down vote up
export async function queryRule(params?: TableListParams) {
  return request('/api/rule', {
    params,
  });
}
Example #8
Source File: api.ts    From anew-server with MIT License 5 votes vote down vote up
export async function queryApis(options?: { [key: string]: any }) {
  return request<API.Result>('/api/v1/api/list', {
    method: 'GET',
    ...(options || {}),
  });
}