diff --git a/src/app/modules/auth/capacitor-requestor.ts b/src/app/modules/auth/capacitor-requestor.ts index 427ab785..2a839887 100644 --- a/src/app/modules/auth/capacitor-requestor.ts +++ b/src/app/modules/auth/capacitor-requestor.ts @@ -34,7 +34,11 @@ export class CapacitorRequestor extends Requestor { private async post(url: string, data: any, headers: HttpHeaders) { return CapacitorHttp.post({ url, - data: this.decodeURLSearchParams(data), + // Workaround for CapacitorHttp bug (JSONException when "x-www-form-urlencoded" text is provided) + data: + headers['Content-Type'] === 'application/x-www-form-urlencoded' + ? this.decodeURLSearchParams(data) + : data, headers, }).then((response: HttpResponse) => { return response.data as T; @@ -45,7 +49,11 @@ export class CapacitorRequestor extends Requestor { private async put(url: string, data: any, headers: HttpHeaders) { return CapacitorHttp.put({ url, - data: this.decodeURLSearchParams(data), + // Workaround for CapacitorHttp bug (JSONException when "x-www-form-urlencoded" text is provided) + data: + headers['Content-Type'] === 'application/x-www-form-urlencoded' + ? this.decodeURLSearchParams(data) + : data, headers, }).then((response: HttpResponse) => response.data as T); }