1
0
Fork 0
mirror of synced 2024-07-18 20:56:04 +12:00
budibase/packages/builder/src/builderStore/api.js
Martin McKeaveney bb2058a010 lint
2020-09-17 16:36:39 +01:00

28 lines
571 B
JavaScript

const apiCall = method => async (
url,
body,
headers = { "Content-Type": "application/json" }
) => {
const response = await fetch(url, {
method: method,
body: body && JSON.stringify(body),
headers,
})
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")
export default {
post: apiCall("POST"),
get: apiCall("GET"),
patch: apiCall("PATCH"),
delete: apiCall("DELETE"),
put: apiCall("PUT"),
}