From 7fc482fef3d09ed9c43d94d4ea02ea744f55e1d3 Mon Sep 17 00:00:00 2001 From: Jan Nino Walter Date: Wed, 28 Feb 2024 13:31:11 +0100 Subject: [PATCH] Don't throw exception if response.json() fails --- core/src/core-plugins.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/core-plugins.ts b/core/src/core-plugins.ts index 7ec429f7c5..e4f689a7fd 100644 --- a/core/src/core-plugins.ts +++ b/core/src/core-plugins.ts @@ -392,7 +392,11 @@ export class CapacitorHttpPluginWeb data = await readBlobAsBase64(blob); break; case 'json': - data = await response.json(); + try { + data = await response.json(); + } catch (e) { + data = ''; + } break; case 'document': case 'text':