Skip to content

Commit

Permalink
convert all fetch functions to use axios
Browse files Browse the repository at this point in the history
  • Loading branch information
bekossy committed May 20, 2024
1 parent fd2201f commit aa706dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
12 changes: 3 additions & 9 deletions agenta-web/src/lib/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ export const createAppFromTemplate = async (
}

export const fetchData = async (url: string): Promise<any> => {
const response = await fetch(url)
return response.json()
const {data} = await axios(url)
return data
}

export const waitForAppToStart = async ({
Expand Down Expand Up @@ -665,13 +665,7 @@ export const createAndStartTemplate = async ({
}

export const fetchEnvironments = async (appId: string): Promise<Environment[]> => {
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
}

Expand Down
4 changes: 2 additions & 2 deletions agenta-web/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ export const createAppFromTemplate = async (
}

export const fetchData = async (url: string): Promise<any> => {
const response = await fetch(url)
return response.json()
const {data} = await axios(url)
return data
}

export const waitForAppToStart = async ({
Expand Down
7 changes: 1 addition & 6 deletions agenta-web/src/services/deployment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import {getAgentaApiUrl} from "@/lib/helpers/utils"
// - delete: DELETE data from server

export const fetchEnvironments = async (appId: string): Promise<Environment[]> => {
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
}

Expand Down

0 comments on commit aa706dc

Please sign in to comment.