diff --git a/agenta-web/src/lib/services/api.ts b/agenta-web/src/lib/services/api.ts index 9bdcc66189..20633a865c 100644 --- a/agenta-web/src/lib/services/api.ts +++ b/agenta-web/src/lib/services/api.ts @@ -563,8 +563,8 @@ export const createAppFromTemplate = async ( } export const fetchData = async (url: string): Promise => { - const response = await fetch(url) - return response.json() + const {data} = await axios(url) + return data } export const waitForAppToStart = async ({ @@ -665,13 +665,7 @@ export const createAndStartTemplate = async ({ } export const fetchEnvironments = async (appId: string): Promise => { - const response = await fetch(`${getAgentaApiUrl()}/api/apps/${appId}/environments/`) - - if (response.status !== 200) { - throw new Error("Failed to fetch environments") - } - - const data: Environment[] = await response.json() + const {data} = await axios(`${getAgentaApiUrl()}/api/apps/${appId}/environments/`) return data } diff --git a/agenta-web/src/services/api.ts b/agenta-web/src/services/api.ts index 2e113c41d3..ebbb62263c 100644 --- a/agenta-web/src/services/api.ts +++ b/agenta-web/src/services/api.ts @@ -253,8 +253,8 @@ export const createAppFromTemplate = async ( } export const fetchData = async (url: string): Promise => { - const response = await fetch(url) - return response.json() + const {data} = await axios(url) + return data } export const waitForAppToStart = async ({ diff --git a/agenta-web/src/services/deployment/index.ts b/agenta-web/src/services/deployment/index.ts index 5a1f94b98e..4f1b9e4ff7 100644 --- a/agenta-web/src/services/deployment/index.ts +++ b/agenta-web/src/services/deployment/index.ts @@ -10,13 +10,8 @@ import {getAgentaApiUrl} from "@/lib/helpers/utils" // - delete: DELETE data from server export const fetchEnvironments = async (appId: string): Promise => { - const response = await fetch(`${getAgentaApiUrl()}/api/apps/${appId}/environments/`) + const {data} = await axios(`${getAgentaApiUrl()}/api/apps/${appId}/environments/`) - if (response.status !== 200) { - throw new Error("Failed to fetch environments") - } - - const data: Environment[] = await response.json() return data }