diff --git a/package.json b/package.json index cf6dc2a6..a6ea25a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stellar/wallet-sdk", - "version": "0.0.8-rc.5", + "version": "0.0.8-rc.6", "description": "Libraries to help you write Stellar-enabled wallets in Javascript", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/transfers/DepositProvider.ts b/src/transfers/DepositProvider.ts index 9e4f184f..6d83ae55 100644 --- a/src/transfers/DepositProvider.ts +++ b/src/transfers/DepositProvider.ts @@ -108,7 +108,15 @@ export class DepositProvider extends TransferProvider { const response = await fetch(`${this.transferServer}/deposit?${qs}`, { headers: isAuthRequired ? this.getHeaders() : undefined, }); - const json = (await response.json()) as TransferResponse; + + const text = await response.text(); + let json; + + try { + json = JSON.parse(text) as TransferResponse; + } catch (e) { + throw new Error(`Error parsing the deposit response as JSON: ${text}`); + } if (json.error) { const error: TransferError = new Error( diff --git a/src/transfers/WithdrawProvider.ts b/src/transfers/WithdrawProvider.ts index 89d7ee98..f7ea9813 100644 --- a/src/transfers/WithdrawProvider.ts +++ b/src/transfers/WithdrawProvider.ts @@ -103,7 +103,15 @@ export class WithdrawProvider extends TransferProvider { const response = await fetch(`${this.transferServer}/withdraw?${qs}`, { headers: isAuthRequired ? this.getHeaders() : undefined, }); - const json = (await response.json()) as TransferResponse; + + const text = await response.text(); + let json; + + try { + json = JSON.parse(text) as TransferResponse; + } catch (e) { + throw new Error(`Error parsing the deposit response as JSON: ${text}`); + } if (json.error) { const error: TransferError = new Error(json.error);