Skip to content

Commit

Permalink
Don't process response body for response status 204
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Nino Walter committed Feb 28, 2024
1 parent fe53330 commit 27d94fc
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions core/src/core-plugins.ts
Expand Up @@ -385,19 +385,23 @@ export class CapacitorHttpPluginWeb

let data: any;
let blob: any;
switch (responseType) {
case 'arraybuffer':
case 'blob':
blob = await response.blob();
data = await readBlobAsBase64(blob);
break;
case 'json':
data = await response.json();
break;
case 'document':
case 'text':
default:
data = await response.text();
if (response.status === 204) {
data = null;
} else {
switch (responseType) {
case 'arraybuffer':
case 'blob':
blob = await response.blob();
data = await readBlobAsBase64(blob);
break;
case 'json':
data = await response.json();
break;
case 'document':
case 'text':
default:
data = await response.text();
}
}

// Convert fetch headers to Capacitor HttpHeaders
Expand Down

0 comments on commit 27d94fc

Please sign in to comment.