Skip to content

Commit

Permalink
frontend: using replaced fetch to axios
Browse files Browse the repository at this point in the history
  • Loading branch information
ischaojie committed Aug 3, 2023
1 parent 1b129e0 commit 0bacc1d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 57 deletions.
31 changes: 16 additions & 15 deletions frontend/src/services/schemas.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@

import axios from "axios";

// /api/models/<name>
export async function getSchema(name: string) {
return await fetch(`/admin/api/schemas/${name}`, {
method: "GET",
})
.then((rsp) => rsp.json())
return await axios
.get(`/admin/api/schemas/${name}`)
.then((rsp) => rsp.data)
.catch((err) => console.error(err));
}

// /api
export async function getMetadata() {
return await fetch("/admin/api", { method: "GET" })
.then((rsp) => rsp.json())
return await axios
.get("/admin/api")
.then((rsp) => rsp.data)
.catch((err) => console.error(err));
}

export async function saveSchemaData(name: string, data: any) {
return await fetch(`/admin/api/schemas/${name}/data`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((rsp) => rsp.json())
return await axios
.post(`/admin/api/schemas/${name}/data`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((rsp) => rsp.data)
.catch((err) => console.error(err));
}
Loading

0 comments on commit 0bacc1d

Please sign in to comment.