umi#RequestConfig TypeScript Examples

The following examples show how to use umi#RequestConfig. 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: app.tsx    From ant-design-pro-V5-multitab with MIT License 6 votes vote down vote up
request: RequestConfig = {
    errorHandler,
    // requestInterceptors: [
    //   (url, options) => {
    //     // 获取token
    //     const token = getToken()
    //     // 接收个配置
    //     if (token) {
    //       return {
    //         url,
    //         options: {
    //           ...options,
    //           headers: { Authorization: `Bearer ${token}` }
    //         },
    //       }
    //     } else {
    //       return { url, options, }
    //     }
    //   }
    // ],
    // errorConfig: {
    //   adaptor: (resData, ctx) => {
    //     return {
    //       data: resData,
    //       success: true,
    //       errorMessage: resData.message,
    //     };
    //   },
    // },
}
Example #2
Source File: app.tsx    From anew-server with MIT License 6 votes vote down vote up
request: RequestConfig = {
  errorHandler: (error: any) => {
    const { response } = error;

    if (!response) {
      notification.error({
        description: '您的网络发生异常,无法连接服务器',
        message: '网络异常',
      });
    }
    throw error;
  },
  requestInterceptors: [authHeaderInterceptor],
  responseInterceptors: [errResponseInterceptor],
}