Skip to content

Commit

Permalink
the first Axios request ist working
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoLeist committed Dec 8, 2023
1 parent 2860815 commit ee8932a
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 144 deletions.
20 changes: 3 additions & 17 deletions convertPheno_client/src/code/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions convertPheno_client/src/code/axiosInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
})

Expand All @@ -20,4 +19,4 @@ axiosInstance.interceptors.request.use(config => {
return Promise.reject(error);
});

export default axiosInstance;
export default axiosInstance;
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function useFileConversions(props) {
api_endpoint,
JSON.stringify(query)
);
return res.json();
return res.data;
},
{
enabled: startFileConversion,
Expand Down
Loading

0 comments on commit ee8932a

Please sign in to comment.