From 0caa69c28cbb2f962b70a1da13659739c1c6dd3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovan=20Kruni=C4=87?= Date: Wed, 2 Nov 2022 18:13:31 +0100 Subject: [PATCH] fix: extend landing period button not working on android Closes #333 --- src/app/modules/auth/capacitor-requestor.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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); }