improver error handling
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s
This commit is contained in:
@@ -17,6 +17,22 @@ export const api = axios.create({
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
// 🔹 Normalize FastAPI errors here
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
// FastAPI HTTPException format
|
||||
const detail =
|
||||
error?.response?.data?.detail ??
|
||||
error?.response?.data?.message ??
|
||||
error.message ??
|
||||
"Unknown error";
|
||||
|
||||
// Always reject with a standard Error
|
||||
return Promise.reject(new Error(detail));
|
||||
}
|
||||
);
|
||||
|
||||
// Queries
|
||||
export const fetchInterfaces = async (): Promise<InterfaceInfo[]> => {
|
||||
const res = await api.get<InterfaceInfo[]>("/network/interfaces");
|
||||
|
||||
Reference in New Issue
Block a user