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

20 lines
488 B
JavaScript
Raw Normal View History

2019-07-28 09:03:11 +02:00
2019-08-19 09:51:01 +02:00
const apiCall = (method, returnResponse) => (url, body) =>
2019-07-28 09:03:11 +02:00
fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json',
},
body: body && JSON.stringify(body),
2019-08-19 09:51:01 +02:00
}).then(r =>
returnResponse ? r.json() : r
);
2019-07-28 09:03:11 +02:00
2019-08-19 09:51:01 +02:00
const post = apiCall("POST", true);
const get = apiCall("GET", true);
const patch = apiCall("PATCH", true);
const del = apiCall("DELETE", false);
2019-07-28 09:03:11 +02:00
export default {
post, get, patch, delete:del
};