mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 22:21:51 +00:00
fix(nui): Don't throw failed to fetch error in browser
This commit is contained in:
1 parent
4529361e92
commit
2fc0aa4de9
1 file changed
+4
@@ -9,6 +9,8 @@
|
||||
* @return returnData - A promise for the data sent back by the NuiCallbacks CB argument
|
||||
*/
|
||||
|
||||
import { isEnvBrowser } from "./misc";
|
||||
|
||||
export async function fetchNui<T = any>(eventName: string, data?: any): Promise<T> {
|
||||
const options = {
|
||||
method: 'post',
|
||||
@@ -18,6 +20,8 @@ export async function fetchNui<T = any>(eventName: string, data?: any): Promise<
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
|
||||
if (isEnvBrowser()) return undefined as any;
|
||||
|
||||
const resourceName = (window as any).GetParentResourceName ? (window as any).GetParentResourceName() : 'nui-frame-app';
|
||||
|
||||
const resp = await fetch(`https://${resourceName}/${eventName}`, options);
|
||||
|
||||
Reference in new issue
Block a user