From ee8932a34aa0f54d8b317f5eed536d6000e8fd4a Mon Sep 17 00:00:00 2001 From: Ivo Leist Date: Fri, 8 Dec 2023 12:17:27 +0100 Subject: [PATCH] the first Axios request ist working --- convertPheno_client/src/code/apis.js | 20 +- convertPheno_client/src/code/axiosInstance.js | 5 +- .../submission/hooks/fileConversions.jsx | 2 +- .../tests/reports/coverage/coverage.xml | 256 +++++++++--------- 4 files changed, 139 insertions(+), 144 deletions(-) diff --git a/convertPheno_client/src/code/apis.js b/convertPheno_client/src/code/apis.js index f96b7930..78aa5220 100644 --- a/convertPheno_client/src/code/apis.js +++ b/convertPheno_client/src/code/apis.js @@ -27,33 +27,19 @@ export async function fileUpload(token, urlprefix, data) { export async function fileConversion(token, urlprefix, data) { try { - const response = await axiosInstance.post(`${urlprefix}api/submission/convert`, data, { + const res = await axiosInstance.post(`${urlprefix}api/submission/convert`, data, { headers: { 'Authorization': token } }); - console.log('response', response); - console.log('response.data', response.data); - return response.data; + console.log('res', res); + return res; } catch (error) { console.error('Error during file conversion:', error); throw error; } } -export async function fileConversionOld(token, urlprefix, data) { - return fetch(`${urlprefix}api/submission/convert`, { - method: "POST", - body: data, - headers: { - "Content-Type": "application/json", - Accept: "application/json", - connection: "keep-alive", - Authorization: token, - }, - }); -} - // TODO // reimplment this function using Axios export async function fileDownload(token, urlprefix, data) { diff --git a/convertPheno_client/src/code/axiosInstance.js b/convertPheno_client/src/code/axiosInstance.js index 40ee32c1..7ff3a030 100644 --- a/convertPheno_client/src/code/axiosInstance.js +++ b/convertPheno_client/src/code/axiosInstance.js @@ -3,8 +3,7 @@ import axios from 'axios'; const axiosInstance = axios.create({ headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Connection': 'keep-alive', + 'Accept': 'application/json' } }) @@ -20,4 +19,4 @@ axiosInstance.interceptors.request.use(config => { return Promise.reject(error); }); -export default axiosInstance; \ No newline at end of file +export default axiosInstance; diff --git a/convertPheno_client/src/code/views/conversion/ components/submission/hooks/fileConversions.jsx b/convertPheno_client/src/code/views/conversion/ components/submission/hooks/fileConversions.jsx index c55e16cc..b45fd4e5 100644 --- a/convertPheno_client/src/code/views/conversion/ components/submission/hooks/fileConversions.jsx +++ b/convertPheno_client/src/code/views/conversion/ components/submission/hooks/fileConversions.jsx @@ -34,7 +34,7 @@ export default function useFileConversions(props) { api_endpoint, JSON.stringify(query) ); - return res.json(); + return res.data; }, { enabled: startFileConversion, diff --git a/convertPheno_server/tests/reports/coverage/coverage.xml b/convertPheno_server/tests/reports/coverage/coverage.xml index 43b8115f..28789cc7 100644 --- a/convertPheno_server/tests/reports/coverage/coverage.xml +++ b/convertPheno_server/tests/reports/coverage/coverage.xml @@ -1,5 +1,5 @@ - + @@ -204,7 +204,7 @@ - + @@ -234,7 +234,7 @@ - + @@ -502,139 +502,145 @@ - - - - - + + + + + + + - - - - - - + + + + - - - - - - - - - - - - + + + + + + + - + + - - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + + + - - - + + + + + - - - - - - + + + + - - - - + + + + - - + - - - - + + + - - + + - - - - - + + + + + - - - + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + @@ -1034,9 +1040,9 @@ - + - + @@ -1080,15 +1086,19 @@ - - - - - - + + + + + + + + + + - + @@ -1129,12 +1139,12 @@ - - - - - - + + + + + +