fix(package/callback): await callback response (#340)

This commit is contained in:
Can Sönmez
2023-05-26 02:04:30 +03:00
committed by GitHub
parent a8ab102bae
commit 467e7f51ac
2 changed files with 4 additions and 4 deletions

View File

@@ -26,12 +26,12 @@ export function triggerClientCallback<T = unknown>(
}
export function onClientCallback(eventName: string, cb: (playerId: number, ...args) => any) {
onNet(`__ox_cb_${eventName}`, (resource: string, key: string, ...args) => {
onNet(`__ox_cb_${eventName}`, async (resource: string, key: string, ...args) => {
const src = source;
let response: any;
try {
response = cb(src, ...args);
response = await cb(src, ...args);
} catch (e: any) {
console.error(`an error occurred while handling callback event ${eventName}`);
console.log(`^3${e.stack}^0`);