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

20 lines
488 B
JavaScript

const apiCall = (method, returnResponse) => (url, body) =>
fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json',
},
body: body && JSON.stringify(body),
}).then(r =>
returnResponse ? r.json() : r
);
const post = apiCall("POST", true);
const get = apiCall("GET", true);
const patch = apiCall("PATCH", true);
const del = apiCall("DELETE", false);
export default {
post, get, patch, delete:del
};