Skip to content

Commit

Permalink
Don't throw exception if json parsing fails, instead return unparsed …
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
Jan Nino Walter committed Mar 5, 2024
1 parent fe53330 commit e1ba6fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/core-plugins.ts
Expand Up @@ -385,14 +385,20 @@ export class CapacitorHttpPluginWeb

let data: any;
let blob: any;
let responseText: string;
switch (responseType) {
case 'arraybuffer':
case 'blob':
blob = await response.blob();
data = await readBlobAsBase64(blob);
break;
case 'json':
data = await response.json();
responseText = await response.text();
try {
data = JSON.parse(responseText);
} catch (e) {
data = responseText;
}
break;
case 'document':
case 'text':
Expand Down

0 comments on commit e1ba6fa

Please sign in to comment.