budibase/packages/builder/src/builderStore/api.js

27 lines
577 B
JavaScript
Raw Normal View History

2020-06-19 18:19:30 +02:00
const apiCall = method => async (url, body) => {
2020-06-18 17:59:31 +02:00
const headers = {
"Content-Type": "application/json",
}
const response = await fetch(url, {
method: method,
body: body && JSON.stringify(body),
2020-06-18 17:59:31 +02:00
headers,
})
2019-07-28 09:03:11 +02:00
2020-05-07 11:53:34 +02:00
return response
}
export const post = apiCall("POST")
export const get = apiCall("GET")
export const patch = apiCall("PATCH")
export const del = apiCall("DELETE")
export const put = apiCall("PUT")
2019-07-28 09:03:11 +02:00
2020-06-19 18:19:30 +02:00
export default {
post: apiCall("POST"),
get: apiCall("GET"),
patch: apiCall("PATCH"),
delete: apiCall("DELETE"),
put: apiCall("PUT"),
}