Skip to content

Commit

Permalink
Merge branch 'main' into 26-create-the-dockerfile-for-the-fertiscan-f…
Browse files Browse the repository at this point in the history
…rontend
  • Loading branch information
ThomasCardin authored May 30, 2024
2 parents 4949b98 + f111496 commit 091e70c
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/Pages/JsonPage/Json.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@ import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import "./Json.css";

function JsonPage() {
const [loading, setLoading] = useState(true);
const [form, setForm] = useState({});
const [fetchError, setError] = useState<Error | null>(null);
const location = useLocation();
const files: File[] = location.state.data[0];
const [uploadStarted, startUpload] = useState(false);
function JsonPage(){
const [loading, setLoading] = useState(true)
const [form, setForm]=useState({})
const [fetchError, setError]=useState<Error|null>(null)
const location = useLocation();
const files:File[] = location.state.data;
const [uploadStarted, startUpload] = useState(false);

const api_url = "http://localhost:5000";
const upload_all = async () => {
for (let i = 0; i < files.length; i++) {
const formData = new FormData();
formData.append("file", files[i]);
await fetch(api_url + "/upload", {
method: "POST",
headers: {
// if needed, add headers here
},
body: formData,
});

const api_url = "https://shiny-goggles-75q6p5xj4wwfp6gg-5000.app.github.dev/"
const upload_all = async ()=>{
const res = []
for(let i=0; i<files.length; i++){
const formData = new FormData()
formData.append("file", files[i])
res.push(await fetch(api_url+"/upload",{
method:'POST',
headers:{
// if needed, add headers here
},
body:formData
}))
}
return res
}
};
useEffect(() => {
Expand Down

0 comments on commit 091e70c

Please sign in to comment.