From 2fc0aa4de9c3938bf1dcb47bab5732f2510d2e3a Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 1 Jan 2022 13:21:17 +0100 Subject: [PATCH] fix(nui): Don't throw failed to fetch error in browser --- ui/src/utils/fetchNui.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/src/utils/fetchNui.ts b/ui/src/utils/fetchNui.ts index 6069465..63da85b 100644 --- a/ui/src/utils/fetchNui.ts +++ b/ui/src/utils/fetchNui.ts @@ -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(eventName: string, data?: any): Promise { const options = { method: 'post', @@ -18,6 +20,8 @@ export async function fetchNui(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);