1
0
Fork 0
mirror of synced 2024-07-09 00:06:05 +12:00
budibase/packages/builder/src/components/backend/DataTable/api.js

33 lines
849 B
JavaScript
Raw Normal View History

import api from "builderStore/api"
2020-03-24 03:26:38 +13:00
2020-06-20 04:19:30 +12:00
export async function createUser(user) {
2020-06-19 03:59:31 +12:00
const CREATE_USER_URL = `/api/users`
const response = await api.post(CREATE_USER_URL, user)
2020-05-15 02:12:30 +12:00
return await response.json()
2020-03-25 05:17:10 +13:00
}
export async function saveRow(row, tableId) {
2020-11-25 06:00:15 +13:00
const SAVE_ROW_URL = `/api/${tableId}/rows`
const response = await api.post(SAVE_ROW_URL, row)
2020-03-24 03:26:38 +13:00
return await response.json()
}
export async function deleteRow(row) {
const DELETE_ROWS_URL = `/api/${row.tableId}/rows/${row._id}/${row._rev}`
const response = await api.delete(DELETE_ROWS_URL)
2020-03-24 03:26:38 +13:00
return response
}
export async function fetchDataForView(view) {
const FETCH_ROWS_URL = `/api/views/${view.name}`
2020-03-13 03:23:29 +13:00
const response = await api.get(FETCH_ROWS_URL)
2020-12-19 07:19:43 +13:00
const json = await response.json()
if (response.status !== 200) {
throw new Error(json.message)
}
return json
}