From 53af8b486fd8a538c1f54a2ce66ed5f74b2b46ed Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 10 Feb 2023 09:50:54 -0300 Subject: fix: request error is whats being thrown --- .../merchant-backoffice-ui/src/hooks/templates.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'packages/merchant-backoffice-ui/src/hooks/templates.ts') diff --git a/packages/merchant-backoffice-ui/src/hooks/templates.ts b/packages/merchant-backoffice-ui/src/hooks/templates.ts index 124786887..579478537 100644 --- a/packages/merchant-backoffice-ui/src/hooks/templates.ts +++ b/packages/merchant-backoffice-ui/src/hooks/templates.ts @@ -13,17 +13,17 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see */ -import { MerchantBackend } from "../declaration.js"; -import { useMatchMutate, useBackendInstanceRequest } from "./backend.js"; -import useSWR from "swr"; -import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils/constants.js"; -import { useEffect, useState } from "preact/hooks"; import { - HttpError, HttpResponse, HttpResponseOk, HttpResponsePaginated, + RequestError, } from "@gnu-taler/web-util/lib/index.browser"; +import { useEffect, useState } from "preact/hooks"; +import useSWR from "swr"; +import { MerchantBackend } from "../declaration.js"; +import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils/constants.js"; +import { useBackendInstanceRequest, useMatchMutate } from "./backend.js"; export function useTemplateAPI(): TemplateAPI { const mutateAll = useMatchMutate(); @@ -148,7 +148,7 @@ export function useInstanceTemplates( isValidating: loadingAfter, } = useSWR< HttpResponseOk, - HttpError + RequestError >([`/private/templates`, args?.position, -totalAfter], templateFetcher); //this will save last result @@ -167,7 +167,7 @@ export function useInstanceTemplates( }, [afterData /*, beforeData*/]); // if (beforeError) return beforeError; - if (afterError) return afterError; + if (afterError) return afterError.info; // if the query returns less that we ask, then we have reach the end or beginning const isReachingEnd = @@ -231,7 +231,7 @@ export function useTemplateDetails( const { data, error, isValidating } = useSWR< HttpResponseOk, - HttpError + RequestError >([`/private/templates/${templateId}`], templateFetcher, { refreshInterval: 0, refreshWhenHidden: false, @@ -242,6 +242,6 @@ export function useTemplateDetails( if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error; + if (error) return error.info; return { loading: true }; } -- cgit v1.2.3