diff --git a/src/contexts/NDKContext.tsx b/src/contexts/NDKContext.tsx index fe9b773..dd5e605 100644 --- a/src/contexts/NDKContext.tsx +++ b/src/contexts/NDKContext.tsx @@ -369,16 +369,14 @@ export const NDKContextProvider = ({ children }: { children: ReactNode }) => { const publish = async (event: NDKEvent): Promise => { if (!event.sig) throw new Error('Before publishing first sign the event!') - return event - .publish(undefined, 10000) - .then((res) => { - const relaysPublishedOn = Array.from(res) - return relaysPublishedOn.map((relay) => relay.url) - }) - .catch((err) => { - console.error(`An error occurred in publishing event`, err) - return [] - }) + try { + const res = await event.publish(undefined, 10000) + const relaysPublishedOn = Array.from(res) + return relaysPublishedOn.map((relay) => relay.url) + } catch (err) { + console.error(`An error occurred in publishing event`, err) + return [] + } } /**