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

@@ -42,11 +42,11 @@ export function triggerServerCallback<T = unknown>(
}
export function onServerCallback(eventName: string, cb: (...args) => any) {
onNet(`__ox_cb_${eventName}`, (resource: string, key: string, ...args) => {
onNet(`__ox_cb_${eventName}`, async (resource: string, key: string, ...args) => {
let response: any;
try {
response = cb(...args);
response = await cb(...args);
} catch (e: any) {
console.error(`an error occurred while handling callback event ${eventName}`);
console.log(`^3${e.stack}^0`);