More work on builder API refactor
This commit is contained in:
parent
e2fb5f51f5
commit
6319760b8c
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import api from "builderStore/api"
|
import { API } from "api"
|
||||||
import { Select, Label, Multiselect } from "@budibase/bbui"
|
import { Select, Label, Multiselect } from "@budibase/bbui"
|
||||||
import { capitalise } from "../../helpers"
|
import { capitalise } from "../../helpers"
|
||||||
|
|
||||||
|
@ -17,12 +17,9 @@
|
||||||
$: fetchRows(linkedTableId)
|
$: fetchRows(linkedTableId)
|
||||||
|
|
||||||
async function fetchRows(linkedTableId) {
|
async function fetchRows(linkedTableId) {
|
||||||
const FETCH_ROWS_URL = `/api/${linkedTableId}/rows`
|
|
||||||
try {
|
try {
|
||||||
const response = await api.get(FETCH_ROWS_URL)
|
rows = await API.fetchTableData(linkedTableId)
|
||||||
rows = await response.json()
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
|
||||||
rows = []
|
rows = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { writable } from "svelte/store"
|
import { writable } from "svelte/store"
|
||||||
import api from "builderStore/api"
|
import { API } from "api"
|
||||||
|
|
||||||
export default function (url) {
|
export default function (url) {
|
||||||
const store = writable({ status: "LOADING", data: {}, error: {} })
|
const store = writable({ status: "LOADING", data: {}, error: {} })
|
||||||
|
@ -7,8 +7,8 @@ export default function (url) {
|
||||||
async function get() {
|
async function get() {
|
||||||
store.update(u => ({ ...u, status: "LOADING" }))
|
store.update(u => ({ ...u, status: "LOADING" }))
|
||||||
try {
|
try {
|
||||||
const response = await api.get(url)
|
const data = await API.get({ url })
|
||||||
store.set({ data: await response.json(), status: "SUCCESS" })
|
store.set({ data, status: "SUCCESS" })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
store.set({ data: {}, error: e, status: "ERROR" })
|
store.set({ data: {}, error: e, status: "ERROR" })
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,14 @@ export const buildAppEndpoints = API => ({
|
||||||
url: "/api/deploy",
|
url: "/api/deploy",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverts an app to a previous version.
|
||||||
|
* @param appId the app ID to revert
|
||||||
|
*/
|
||||||
|
revertApp: async appId => {
|
||||||
|
return await API.post({
|
||||||
|
url: `/api/dev/${appId}/revert`,
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue