UNPKG

@_lan/web-libs

Version:

<div align="center"> <img src="./public/favicon.svg" width="160" /> <h1>SoybeanAdmin AntDesign</h1> <span>中文 | <a href="./README.en_US.md">English</a></span> </div>

29 lines (23 loc) 727 B
import type { AxiosHeaderValue, AxiosResponse, InternalAxiosRequestConfig } from 'axios'; export function getContentType(config: InternalAxiosRequestConfig) { const contentType: AxiosHeaderValue = config.headers?.['Content-Type'] || 'application/json'; return contentType; } /** * check if http status is success * * @param status */ export function isHttpSuccess(status: number) { const isSuccessCode = status >= 200 && status < 300; return isSuccessCode || status === 304; } /** * is response json * * @param response axios response */ export function isResponseJson(response: AxiosResponse) { const { responseType } = response.config; return responseType === 'json' || responseType === undefined; }