From 1a9f08cbba904c77c836114d299f16cb66d9937a Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 22 Aug 2022 11:45:51 -0400 Subject: [PATCH] *Add error to RPCResponse, dont put inside data --- src/rpc.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/rpc.ts b/src/rpc.ts index e0b2d36..7c0bcab 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -49,11 +49,8 @@ interface RPCRequest { interface RPCResponse { updated: number; - data: - | any - | { - error: string | boolean; - }; + data: any; + error?: string; } function hash(data: string): string { @@ -137,9 +134,11 @@ async function processRequest(request: RPCRequest): Promise { } } - dbData.data = error - ? { error } - : (rpcResp as unknown as JSONRPCResponseWithResult).result; + if (error) { + dbData.error = error as string; + } else { + dbData.data = (rpcResp as unknown as JSONRPCResponseWithResult).result; + } if ( (!processedRequests.get(reqId) || request.bypassCache) &&