diff options
author | Sebastian <sebasjm@gmail.com> | 2023-12-13 15:15:37 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-12-13 15:15:37 -0300 |
commit | cd1201ef6c737b007adf1c3c572b41d793f2296b (patch) | |
tree | 8fc1972aa419b252d69f27c44f86a1cbde1cb604 /packages/web-util/src/utils/http-impl.browser.ts | |
parent | 145c36e9ba549b7ccc72a29eaf102879011060a4 (diff) | |
download | wallet-core-cd1201ef6c737b007adf1c3c572b41d793f2296b.tar.xz |
fix withdraw-exchange redirect when there is not amount
Diffstat (limited to 'packages/web-util/src/utils/http-impl.browser.ts')
-rw-r--r-- | packages/web-util/src/utils/http-impl.browser.ts | 32 |
1 files changed, 17 insertions, 15 deletions
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( |