1
0
Fork 0
mirror of synced 2024-09-10 06:26:02 +12:00
budibase/packages/builder/src/builderStore/api.js

20 lines
488 B
JavaScript
Raw Normal View History

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