How to use the umi.request function in umi

To help you get started, we’ve selected a few umi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / apisix-dashboard / web / src / pages / User / components / LoginMethodPassword.tsx View on Github external
submit: async ({ username, password }) => {
    if (username !== '' && password !== '') {
      try {
        const result = await request('/user/login', {
          method: 'POST',
          requestType: 'json',
          data: {
            username,
            password,
          },
        });

        localStorage.setItem('token', result.data.token);
        return {
          status: true,
          message: formatMessage({ id: 'component.user.loginMethodPassword.success' }),
          data: [],
        };
      } catch (e) {
        // NOTE: API failed, using errorHandler
github apache / apisix-dashboard / web / src / pages / Route / service.ts View on Github external
export const fetchUpstreamItem = (sid: string) => {
  return request(`/upstreams/${sid}`).then(({ nodes, timeout, id }) => {
    return {
      upstreamHostList: transformUpstreamNodes(nodes),
      timeout,
      upstream_id: id,
    };
  });
};
github apache / apisix-dashboard / web / src / pages / Upstream / service.ts View on Github external
export const create = (data: UpstreamModule.RequestBody) =>
  request('/upstreams', {
    method: 'POST',
    data,
  });
github apache / apisix-dashboard / web / src / components / Upstream / service.ts View on Github external
export const fetchUpstreamList = () => {
  return request>>('/upstreams').then(({ data }) => ({
    data: data.rows.map(row => convertToFormData(row)),
    total: data.total_size,
  }));
};
github oam-dev / kubevela / references / dashboard / src / services / environment.ts View on Github external
export async function updateEnvironment(
  envName: string,
  body: API.EnvironmentBody,
): Promise> {
  return request(`${BASE_PATH}/${envName}`, {
    method: 'put',
    data: body,
  });
}
github apache / apisix-dashboard / web / src / pages / Route / service.ts View on Github external
export const checkUniqueName = (name = '', exclude = '') =>
  request('/notexist/routes', {
    params: pickBy(
      {
        name,
        exclude,
      },
      identity,
    ),
  });
github apache / apisix-dashboard / src / components / PluginPage / service.ts View on Github external
export const fetchPluginList = () => request('/plugins');
github apache / apisix-dashboard / web / src / components / Plugin / service.ts View on Github external
export const fetchList = () => {
  if (cached.list.length) {
    return Promise.resolve(cached.list)
  }

  return request>('/plugins?all=true').then((data) => {
    const typedData = data.data.map(item => ({
      ...item,
      type: PLUGIN_LIST[item.name]?.type || "other",
      hidden: PLUGIN_LIST[item.name]?.hidden || false
    }));

    let finalList: PluginComponent.Meta[] = []

    Object.values(PluginType).forEach(type => {
      finalList = finalList.concat(typedData.filter(item => item.type === type))
    })

    if (cached.list.length === 0) {
      cached.list = finalList
    }
github apache / apisix-dashboard / web / src / pages / Plugin / service.ts View on Github external
export const fetchPluginList = () => {
  return request>('/plugins?all=true').then((data) => {
    return data.data;
  });
};
github apache / apisix-dashboard / frontend / src / pages / SSL / service.ts View on Github external
export const verifyKeyPaire = (cert = '', key = ''): Promise =>
  request('/check_ssl_cert', {
    method: 'POST',
    data: { cert, key },
  });