This commit is contained in:
Nordi98 2025-08-11 16:51:34 +02:00
parent 600d79af31
commit 5d11084641
136 changed files with 12007 additions and 584 deletions

View file

@ -0,0 +1,28 @@
export default async function fetchNui(eventName: string, data: unknown = {}) {
const options = {
method: 'post',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify(data),
};
const getResourceName = () => {
try {
// @ts-ignore
return window.GetParentResourceName();
} catch (err) {
return 'ps-ui';
}
};
const resourceName = getResourceName();
try {
const resp = await fetch(
`https://${resourceName}/${eventName}`,
options
);
return await resp.json();
} catch (err) {}
}