From f4b0897b35606a579bdd6e0c982bd5218d484d1b Mon Sep 17 00:00:00 2001 From: luxn Date: Tue, 24 Mar 2020 20:25:14 +0100 Subject: [PATCH 1/4] url fix in Api.js --- client/src/api/Api.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/api/Api.js b/client/src/api/Api.js index 1e9bdca9..ab4a700f 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -4,14 +4,14 @@ class Api { location.host.includes("localhost") || location.host.includes("127.0.0.1") ) { - this.BASE_URL = "http://localhost:8080"; + this.BASE_URL = "https://api.imis-prototyp.de"; } else { this.BASE_URL = "https://api.imis-prototyp.de"; } } getCall(url) { - return fetch(encodeURI(`${this.BASE_URL}/${url}`), { + return fetch(`${this.BASE_URL}${encodeURI(url)}`, { method: "GET", headers: { "Content-Type": "application/json" @@ -22,7 +22,7 @@ class Api { } postCall(url, body) { - return fetch(encodeURI(`${this.BASE_URL}/${url}`), { + return fetch(`${this.BASE_URL}${encodeURI(url)}`, { method: "POST", headers: { "Content-Type": "application/json" @@ -34,7 +34,7 @@ class Api { } putCall(url, body) { - return fetch(encodeURI(`${this.BASE_URL}/${url}`), { + return fetch(`${this.BASE_URL}${encodeURI(url)}`, { method: "PUT", headers: { "Content-Type": "application/json" @@ -46,7 +46,7 @@ class Api { } deleteCall(url) { - return fetch(encodeURI(`${this.BASE_URL}/${url}`), { + return fetch(`${this.BASE_URL}${encodeURI(url)}`, { method: "DELETE", headers: { "Content-Type": "application/json" From a10b70b8918d4c335dd3f07255bffa04934a08ba Mon Sep 17 00:00:00 2001 From: luxn Date: Tue, 24 Mar 2020 20:26:19 +0100 Subject: [PATCH 2/4] Api.js: fix in putLabtest RequestBody --- client/src/api/Api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/api/Api.js b/client/src/api/Api.js index ab4a700f..7be47f55 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -91,7 +91,7 @@ class Api { } putLabtest({ updatedTestStatus }) { - return this.postCall("/labtest", updatedTestStatus); + return this.postCall("/labtest", { updatedTestStatus }); } getLabtestByPatient(patientId) { From 52853b15a50611ed89aeef17e71e7080e8fac0b6 Mon Sep 17 00:00:00 2001 From: luxn Date: Tue, 24 Mar 2020 20:54:50 +0100 Subject: [PATCH 3/4] added FileUpload to Api.js --- client/src/api/Api.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/client/src/api/Api.js b/client/src/api/Api.js index 7be47f55..23528a59 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -72,14 +72,26 @@ class Api { return this.getCall(`/test_report/${testId}`); } - // TODO: postTestReport, putTestReport | how to handle multipart/form-data in fetch ?! + postTestReport(id, file) { + + data = new FormData() + data.append('file', file) + + + return fetch(`${this.BASE_URL}/test_reports/${encodeURI(id)}`, { + method: "POST", + body: data + }).then(response => { + return response.json(); + }); + } getTestReport(testId) { - return this.getCall(`/test_report/${testId}`); + return this.getCall(`/test_reports/${testId}`); } deleteTestReport(testId) { - return this.deleteCall(`/test_report/${testId}`); + return this.deleteCall(`/test_reports/${testId}`); } postInstitution(institution) { From b6660ca4f4d012820f762914f7ca5b010a3b370f Mon Sep 17 00:00:00 2001 From: luxn Date: Tue, 24 Mar 2020 21:03:36 +0100 Subject: [PATCH 4/4] Api.js fix --- client/src/api/Api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/api/Api.js b/client/src/api/Api.js index 23528a59..ea3b0cb8 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -74,7 +74,7 @@ class Api { postTestReport(id, file) { - data = new FormData() + const data = new FormData() data.append('file', file)