|
Server : Apache System : Linux s1230 5.15.0-139-generic #149~20.04.1 SMP Tue Jul 14 11:21:49 UTC 2026 x86_64 User : p141464 ( 418825) PHP Version : 7.4.33.12 Disable Function : NONE Directory : /html/KMU-CSR-PLANER/wp-content/plugins/themeisle-companion/dashboard/src/utils/ |
Upload File : |
/* global obfxDash */
import fetch from 'node-fetch';
export const requestData = async (
route,
simple = false,
data = {},
urlEncoded = false,
method = 'POST'
) => {
const options = {
method,
headers: {
Accept: 'application/json',
'Content-Type': urlEncoded
? 'application/x-www-form-urlencoded'
: 'application/json',
'x-wp-nonce': obfxDash.nonce,
},
};
if ('POST' === method) {
options.body = urlEncoded ? data : JSON.stringify(data);
}
return await fetch(route, options).then((response) => {
return simple ? response : response.json();
});
};
export const get = (route, simple) => {
return requestData(route, simple, {}, 'GET');
};
export const post = (route, data) => {
return requestData(route, false, data, true);
};