From 6b8fc0477e7c777dbd7f97e01a6a67a075d173d5 Mon Sep 17 00:00:00 2001 From: stdpi Date: Fri, 29 Nov 2024 00:41:58 +0700 Subject: [PATCH] fix: weird structure corrected --- src/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 7cbf9c4..c1881cc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,7 +38,16 @@ async function execute( ) } - return response.json() as TResult + const responseObject = await response.json() + + if (!response || !responseObject.data) { + console.log(responseObject) + throw new Error( + 'WTClientRequestError: Malformed JSON data' + ) + } + + return responseObject.data as TResult } export default class WTClient {