本文整理汇总了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;未经允许,请勿转载。 |
请发表评论