Skip to content

Commit

Permalink
fixed upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Youllou committed May 30, 2024
1 parent d695ffd commit 13e2137
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Pages/JsonPage/Json.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ function JsonPage(){
const [form, setForm]=useState({})
const [fetchError, setError]=useState<Error|null>(null)
const location = useLocation();
const files:File[] = location.state.data[0];
const files:File[] = location.state.data;
const [uploadStarted, startUpload] = useState(false);


const api_url = "http://localhost:5000"
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])
await fetch(api_url+"/upload",{
res.push(await fetch(api_url+"/upload",{
method:'POST',
headers:{
// if needed, add headers here
},
body:formData
})
}))
}
return res
}
useEffect(()=>{
if(!uploadStarted){
Expand Down

0 comments on commit 13e2137

Please sign in to comment.