1
0
Fork 0
mirror of synced 2024-08-31 17:51:11 +12:00
budibase/packages/builder/src/builderStore/api.js

28 lines
571 B
JavaScript
Raw Normal View History

const apiCall = method => async (
2020-09-18 03:36:39 +12:00
url,
body,
headers = { "Content-Type": "application/json" }
) => {
const response = await fetch(url, {
method: method,
body: body && JSON.stringify(body),
2020-06-19 03:59:31 +12:00
headers,
})
2019-07-28 19:03:11 +12:00
2020-05-07 21:53:34 +12: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 19:03:11 +12:00
2020-06-20 04:19:30 +12:00
export default {
post: apiCall("POST"),
get: apiCall("GET"),
patch: apiCall("PATCH"),
delete: apiCall("DELETE"),
put: apiCall("PUT"),
}