aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Application.tsx6
-rw-r--r--packages/web-util/src/utils/http-impl.browser.ts32
-rw-r--r--packages/web-util/src/utils/http-impl.sw.ts28
3 files changed, 34 insertions, 32 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx
index 7bd4195ee..df0e968b9 100644
--- a/packages/taler-wallet-webextension/src/wallet/Application.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx
@@ -404,10 +404,8 @@ export function Application(): VNode {
}) => (
<CallToActionTemplate title={i18n.str`Digital cash withdrawal`}>
<WithdrawPageFromParams
- onAmountChanged={async (e) => {
- const page = `${Pages.ctaWithdrawManual({
- amount,
- })}?talerUri=${encodeURIComponent(talerUri)}`;
+ onAmountChanged={async (newamount) => {
+ const page = `${Pages.ctaWithdrawManual({ amount: newamount })}?talerUri=${encodeURIComponent(talerUri)}`;
redirectTo(page);
}}
talerExchangeWithdrawUri={talerUri}
diff --git a/packages/web-util/src/utils/http-impl.browser.ts b/packages/web-util/src/utils/http-impl.browser.ts
index db789a536..974a7d1b8 100644
--- a/packages/web-util/src/utils/http-impl.browser.ts
+++ b/packages/web-util/src/utils/http-impl.browser.ts
@@ -140,22 +140,24 @@ export class BrowserHttpLib implements HttpRequestLibrary {
const td = new TextDecoder();
return td.decode(myRequest.response);
};
+ let responseJson: unknown = undefined;
const makeJson = async (): Promise<any> => {
- let responseJson;
- try {
- const td = new TextDecoder();
- const responseString = td.decode(myRequest.response);
- responseJson = JSON.parse(responseString);
- } catch (e) {
- throw TalerError.fromDetail(
- TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
- {
- requestUrl,
- requestMethod,
- httpStatusCode: myRequest.status,
- },
- "Invalid JSON from HTTP response",
- );
+ if (responseJson === undefined) {
+ try {
+ const td = new TextDecoder();
+ const responseString = td.decode(myRequest.response);
+ responseJson = JSON.parse(responseString);
+ } catch (e) {
+ throw TalerError.fromDetail(
+ TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
+ {
+ requestUrl,
+ requestMethod,
+ httpStatusCode: myRequest.status,
+ },
+ "Invalid JSON from HTTP response",
+ );
+ }
}
if (responseJson === null || typeof responseJson !== "object") {
throw TalerError.fromDetail(
diff --git a/packages/web-util/src/utils/http-impl.sw.ts b/packages/web-util/src/utils/http-impl.sw.ts
index aab88021f..295681b53 100644
--- a/packages/web-util/src/utils/http-impl.sw.ts
+++ b/packages/web-util/src/utils/http-impl.sw.ts
@@ -176,20 +176,22 @@ function makeJsonHandler(
requestUrl: string,
requestMethod: string,
) {
+ let responseJson: unknown = undefined;
return async function getJsonFromResponse(): Promise<any> {
- let responseJson;
- try {
- responseJson = await response.json();
- } catch (e) {
- throw TalerError.fromDetail(
- TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
- {
- requestUrl,
- requestMethod,
- httpStatusCode: response.status,
- },
- "Invalid JSON from HTTP response",
- );
+ if (responseJson === undefined) {
+ try {
+ responseJson = await response.json();
+ } catch (e) {
+ throw TalerError.fromDetail(
+ TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
+ {
+ requestUrl,
+ requestMethod,
+ httpStatusCode: response.status,
+ },
+ "Invalid JSON from HTTP response",
+ );
+ }
}
if (responseJson === null || typeof responseJson !== "object") {
throw TalerError.fromDetail(