mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-16 06:30:02 +00:00
feat(web): Unified frontend code style (#1923)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: 谨欣 <echo.cmy@antgroup.com> Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com> Co-authored-by: yanzhiyong <932374019@qq.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { AxiosError } from 'axios';
|
||||
import { ApiResponse, FailedTuple, SuccessTuple, ResponseType } from '../';
|
||||
import { notification } from 'antd';
|
||||
import { AxiosError } from 'axios';
|
||||
import { ApiResponse, FailedTuple, ResponseType, SuccessTuple } from '../';
|
||||
|
||||
/**
|
||||
* Response processing
|
||||
@@ -9,9 +9,12 @@ import { notification } from 'antd';
|
||||
* @param ignoreCodes ignore error codes
|
||||
* @returns
|
||||
*/
|
||||
export const apiInterceptors = <T = any, D = any>(promise: Promise<ApiResponse<T, D>>, ignoreCodes?: '*' | (number | string)[]) => {
|
||||
export const apiInterceptors = <T = any, D = any>(
|
||||
promise: Promise<ApiResponse<T, D>>,
|
||||
ignoreCodes?: '*' | (number | string)[],
|
||||
) => {
|
||||
return promise
|
||||
.then<SuccessTuple<T, D>>((response) => {
|
||||
.then<SuccessTuple<T, D>>(response => {
|
||||
const { data } = response;
|
||||
if (!data) {
|
||||
throw new Error('Network Error!');
|
||||
@@ -34,7 +37,9 @@ export const apiInterceptors = <T = any, D = any>(promise: Promise<ApiResponse<T
|
||||
try {
|
||||
const { err_msg } = JSON.parse(err.request.response) as ResponseType<null>;
|
||||
err_msg && (errMessage = err_msg);
|
||||
} catch (e) {}
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
notification.error({
|
||||
message: `Request error`,
|
||||
|
Reference in New Issue
Block a user