2024-12-18 20:25:10 +00:00

28 lines
616 B
JavaScript

jfa.utilities.request = (function () {
async function del(url, data) {
return await _fetch(url, data, "DELETE");
}
async function _fetch(url, data, method) {
const response = await fetch(url, {
method: method,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-XSRF-TOKEN': jfa.page.getAntiForgeryToken()
},
body: data ? JSON.stringify(data) : data
});
return response;
}
async function post(url, data) {
return await _fetch(url, data, "POST");
}
return {
delete: del,
post: post
};
})();