Options
All
  • Public
  • Public/Protected
  • All
Menu

External module @tomato-js/request

Index

Type aliases

Functions

Type aliases

RequestInstance

RequestInstance: AxiosInstance

Functions

get

  • get(url: string, settings?: AxiosRequestConfig): Promise<AxiosResponse<any>>

getIns

  • getIns(settings?: Settings): AxiosInstance
  • 详细配置一个request实例

    脚本举例

      import { getIns } from '@tomato-js/request'
      const myRequest = getIns({
        responseInterceptors: [
          {
            onFulfilled: response => {
              response.data.hello = "me";
              return response;
            },
            onRejected: error => {
              return Promise.reject(error);
            }
          }
        ]
      });
      const response = await myRequest.post("/post.json", {
        option: "lala"
      });

    Parameters

    • Default value settings: Settings = {}

      配置,和axios保持一致

    Returns AxiosInstance

    request实例

post

  • post(url: string, settings?: AxiosRequestConfig): Promise<AxiosResponse<any>>
  • 简易post方法

    脚本举例

      import { post } from '@tomato-js/request'
      const { data } = await post('/api.json',{
        data: {
          str: 'str'
        }
      });

    Parameters

    • url: string

      请求路径

    • Optional settings: AxiosRequestConfig

      配置,和axios保持一致

    Returns Promise<AxiosResponse<any>>

    Promise

request

  • request(settings: AxiosRequestConfig): AxiosPromise<any>

Generated using TypeDoc