當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript axios.isCancel函數代碼示例

本文整理匯總了TypeScript中axios.isCancel函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isCancel函數的具體用法?TypeScript isCancel怎麽用?TypeScript isCancel使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isCancel函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: curry

  const convertResponse = curry((startedAt: number, axiosResult: AxiosResponse | AxiosError) => {
    const end: number = toNumber(new Date())
    const duration: number = end - startedAt

    // new in Axios 0.13 -- some data could be buried 1 level now
    const isError = axiosResult instanceof Error || axios.isCancel(axiosResult)
    const axiosResponse = axiosResult as AxiosResponse
    const axiosError = axiosResult as AxiosError
    const response = isError ? axiosError.response : axiosResponse
    const status = (response && response.status) || null
    const problem = isError ? getProblemFromError(axiosResult) : getProblemFromStatus(status)
    const originalError = isError ? axiosError : null
    const ok = in200s(status)
    const config = axiosResult.config || null
    const headers = (response && response.headers) || null
    let data = (response && response.data) || null

    // give an opportunity for anything to the response transforms to change stuff along the way
    let transformedResponse = {
      duration,
      problem,
      originalError,
      ok,
      status,
      headers,
      config,
      data,
    }
    if (responseTransforms.length > 0) {
      forEach(transform => transform(transformedResponse), responseTransforms)
    }

    return transformedResponse
  })
開發者ID:skellock,項目名稱:apisauce,代碼行數:34,代碼來源:apisauce.ts

示例2: dispatch

 }).catch(error => {
     if (axios.isCancel(error)) {
         console.warn(error.message);
     } else {
         dispatch({ ...payload, type: failureType, ...onError(error) });
     }
 });
開發者ID:terranodo,項目名稱:eventkit-cloud,代碼行數:7,代碼來源:middlewares.ts

示例3: handleReqError

function handleReqError(err, onError) {
  if (Axios.isCancel(err)) {
    return Promise.reject(err);
  }

  if (_.isFunction(onError)) {
    return onError(err);
  }

  return Promise.reject(err);
}
開發者ID:xlsdg,項目名稱:umi-dva-antd-typescript-starter,代碼行數:11,代碼來源:request.ts

示例4: cond

export const getProblemFromError = error => {
  // first check if the error message is Network Error (set by axios at 0.12) on platforms other than NodeJS.
  if (error.message === 'Network Error') return NETWORK_ERROR
  if (axios.isCancel(error)) return CANCEL_ERROR

  // then check the specific error code
  return cond([
    // if we don't have an error code, we have a response status
    [isNil, () => getProblemFromStatus(statusNil(error.response))],
    [containsText(TIMEOUT_ERROR_CODES), always(TIMEOUT_ERROR)],
    [containsText(NODEJS_CONNECTION_ERROR_CODES), always(CONNECTION_ERROR)],
    [T, always(UNKNOWN_ERROR)],
  ])(error.code)
}
開發者ID:skellock,項目名稱:apisauce,代碼行數:14,代碼來源:apisauce.ts

示例5:

 .catch(error => (axios.isCancel(error) ? Promise.resolve('') : Promise.reject(error)));
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:1,代碼來源:openGraph.ts


注:本文中的axios.isCancel函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。