This commit is contained in:
Nordi98 2025-08-06 16:37:06 +02:00
parent 510e3ffcf2
commit f43cf424cf
305 changed files with 34683 additions and 0 deletions

View file

@ -0,0 +1,26 @@
export const fetchNui = async (cbName, data = {}) => {
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify(data)
};

try {
const resourceName = window.GetParentResourceName?.() || '';
const resp = await fetch(`https://${resourceName}/${cbName}`, options);
if (!resp.ok) {
throw new Error(`HTTP error! status: ${resp.status}`);
}
return await resp.json();
} catch (error) {
console.error(`Fetch error for ${cbName}:`, error);
if (!window.GetParentResourceName?.()) {
console.error('Resource name is null - are you testing in browser?');
}
return null;
}
};