From 0ab7114b2d88f306774c0e6cb8d14ec63a453dd2 Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 22 Apr 2025 11:00:22 +0800 Subject: [PATCH] update --- src/graphql/index.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/graphql/index.ts b/src/graphql/index.ts index 89cef044..623b653a 100644 --- a/src/graphql/index.ts +++ b/src/graphql/index.ts @@ -43,29 +43,24 @@ const query: { [key: string]: string } = { ...asyncProfile, }; class Graphql { - private queryData = ""; - public query(queryData: string) { + queryData = ""; + query(queryData: string) { this.queryData = queryData; return this; } - public params(variables: unknown) { - return httpQuery({ + async params(variables: unknown) { + const response = await httpQuery({ method: "post", headers: {}, json: { query: query[this.queryData], variables, }, - }) - .then((response) => { - if (response.errors) { - response.errors = response.errors.map((e: { message: string }) => e.message).join(" "); - } - return response; - }) - .catch((err: Error) => { - throw err; - }); + }); + if (response.errors) { + response.errors = response.errors.map((e: { message: string }) => e.message).join(" "); + } + return response; } }